2 * Copyright (c) 2004-2006, 2008, 2009, 2011-2013, 2015, 2017, 2018 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #ifndef __DNSINFO_CREATE_H__
25 #define __DNSINFO_CREATE_H__
28 * These routines provide access to the systems DNS configuration
31 #include <TargetConditionals.h>
32 #include <os/availability.h>
33 #include <sys/cdefs.h>
35 #include <sys/types.h>
36 #include <sys/socket.h>
37 #include <netinet/in.h>
41 typedef const struct __dns_create_config
* dns_create_config_t
;
42 typedef const struct __dns_create_resolver
* dns_create_resolver_t
;
44 #ifndef _PATH_RESOLVER_DIR
46 #define _PATH_RESOLVER_DIR "/etc/resolver"
48 #define _PATH_RESOLVER_DIR "/Library/Preferences/SystemConfiguration/resolver"
55 * DNS configuration creation APIs
58 _dns_configuration_create (void) API_AVAILABLE(macos(10.4), ios(2.0));
61 _dns_configuration_add_resolver (dns_create_config_t
*_config
,
62 dns_create_resolver_t _resolver
) API_AVAILABLE(macos(10.4), ios(2.0));
65 _dns_configuration_signature (dns_create_config_t
*_config
,
66 unsigned char *signature
,
67 size_t signature_len
) API_AVAILABLE(macos(10.7), ios(5.0)); // signature_len >= CC_SHA256_DIGEST_LENGTH
70 _dns_configuration_free (dns_create_config_t
*_config
) API_AVAILABLE(macos(10.4), ios(2.0));
73 * DNS [resolver] configuration creation APIs
76 _dns_resolver_create (void) API_AVAILABLE(macos(10.4), ios(2.0));
79 _dns_resolver_set_domain (dns_create_resolver_t
*_resolver
,
80 const char *domain
) API_AVAILABLE(macos(10.4), ios(2.0));
83 _dns_resolver_add_nameserver (dns_create_resolver_t
*_resolver
,
84 struct sockaddr
*nameserver
) API_AVAILABLE(macos(10.4), ios(2.0));
87 _dns_resolver_add_search (dns_create_resolver_t
*_resolver
,
88 const char *search
) API_AVAILABLE(macos(10.4), ios(2.0));
91 _dns_resolver_add_sortaddr (dns_create_resolver_t
*_resolver
,
92 dns_sortaddr_t
*sortaddr
) API_AVAILABLE(macos(10.4), ios(2.0));
95 _dns_resolver_set_configuration_identifier
96 (dns_create_resolver_t
*_resolver
,
97 const char *config_identifier
) API_AVAILABLE(macos(10.11), ios(9.0));
100 _dns_resolver_set_flags (dns_create_resolver_t
*_resolver
,
101 uint32_t flags
) API_AVAILABLE(macos(10.7), ios(4.0));
104 _dns_resolver_set_if_index (dns_create_resolver_t
*_resolver
,
106 const char *if_name
) API_AVAILABLE(macos(10.7), ios(4.0));
109 _dns_resolver_set_options (dns_create_resolver_t
*_resolver
,
110 const char *options
) API_AVAILABLE(macos(10.4), ios(2.0));
113 _dns_resolver_set_order (dns_create_resolver_t
*_resolver
,
114 uint32_t order
) API_AVAILABLE(macos(10.4), ios(2.0));
117 _dns_resolver_set_port (dns_create_resolver_t
*_resolver
,
118 uint16_t port
) API_AVAILABLE(macos(10.4), ios(2.0)); // host byte order
121 _dns_resolver_set_timeout (dns_create_resolver_t
*_resolver
,
122 uint32_t timeout
) API_AVAILABLE(macos(10.4), ios(2.0));
125 _dns_resolver_set_service_identifier
126 (dns_create_resolver_t
*_resolver
,
127 uint32_t service_identifier
) API_AVAILABLE(macos(10.9), ios(7.0));
130 _dns_resolver_free (dns_create_resolver_t
*_resolver
) API_AVAILABLE(macos(10.4), ios(2.0));
133 * DNS [resolver] flat-file configuration creation APIs
136 _dnsinfo_flatfile_add_resolvers (dns_create_config_t
*config
) API_AVAILABLE(macos(10.6)) SPI_AVAILABLE(ios(10.15), tvos(13.0), watchos(6.0), bridgeos(6.0));
139 _dnsinfo_flatfile_set_flags (uint32_t flags
) API_AVAILABLE(macos(10.9)) SPI_AVAILABLE(ios(10.15), tvos(13.0), watchos(6.0), bridgeos(6.0));
143 #endif /* __DNSINFO_CREATE_H__ */