2 * Copyright (c) 2004-2006, 2008, 2009, 2011-2013, 2015, 2017 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 <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
;
45 #ifndef _PATH_RESOLVER_DIR
46 #define _PATH_RESOLVER_DIR "/etc/resolver"
48 #endif /* !TARGET_OS_IPHONE */
53 * DNS configuration creation APIs
56 _dns_configuration_create (void) __OSX_AVAILABLE_STARTING(__MAC_10_4
,__IPHONE_2_0
);
59 _dns_configuration_add_resolver (dns_create_config_t
*_config
,
60 dns_create_resolver_t _resolver
) __OSX_AVAILABLE_STARTING(__MAC_10_4
,__IPHONE_2_0
);
63 _dns_configuration_signature (dns_create_config_t
*_config
,
64 unsigned char *signature
,
65 size_t signature_len
) __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_5_0
); // signature_len >= CC_SHA1_DIGEST_LENGTH
68 _dns_configuration_free (dns_create_config_t
*_config
) __OSX_AVAILABLE_STARTING(__MAC_10_4
,__IPHONE_2_0
);
71 * DNS [resolver] configuration creation APIs
74 _dns_resolver_create (void) __OSX_AVAILABLE_STARTING(__MAC_10_4
,__IPHONE_2_0
);
77 _dns_resolver_set_domain (dns_create_resolver_t
*_resolver
,
78 const char *domain
) __OSX_AVAILABLE_STARTING(__MAC_10_4
,__IPHONE_2_0
);
81 _dns_resolver_add_nameserver (dns_create_resolver_t
*_resolver
,
82 struct sockaddr
*nameserver
) __OSX_AVAILABLE_STARTING(__MAC_10_4
,__IPHONE_2_0
);
85 _dns_resolver_add_search (dns_create_resolver_t
*_resolver
,
86 const char *search
) __OSX_AVAILABLE_STARTING(__MAC_10_4
,__IPHONE_2_0
);
89 _dns_resolver_add_sortaddr (dns_create_resolver_t
*_resolver
,
90 dns_sortaddr_t
*sortaddr
) __OSX_AVAILABLE_STARTING(__MAC_10_4
,__IPHONE_2_0
);
93 _dns_resolver_set_configuration_identifier
94 (dns_create_resolver_t
*_resolver
,
95 const char *config_identifier
) __OSX_AVAILABLE_STARTING(__MAC_10_11
,__IPHONE_9_0
);
98 _dns_resolver_set_flags (dns_create_resolver_t
*_resolver
,
99 uint32_t flags
) __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_4_0
);
102 _dns_resolver_set_if_index (dns_create_resolver_t
*_resolver
,
104 const char *if_name
) __OSX_AVAILABLE_STARTING(__MAC_10_7
,__IPHONE_4_0
);
107 _dns_resolver_set_options (dns_create_resolver_t
*_resolver
,
108 const char *options
) __OSX_AVAILABLE_STARTING(__MAC_10_4
,__IPHONE_2_0
);
111 _dns_resolver_set_order (dns_create_resolver_t
*_resolver
,
112 uint32_t order
) __OSX_AVAILABLE_STARTING(__MAC_10_4
,__IPHONE_2_0
);
115 _dns_resolver_set_port (dns_create_resolver_t
*_resolver
,
116 uint16_t port
) __OSX_AVAILABLE_STARTING(__MAC_10_4
,__IPHONE_2_0
); // host byte order
119 _dns_resolver_set_timeout (dns_create_resolver_t
*_resolver
,
120 uint32_t timeout
) __OSX_AVAILABLE_STARTING(__MAC_10_4
,__IPHONE_2_0
);
123 _dns_resolver_set_service_identifier
124 (dns_create_resolver_t
*_resolver
,
125 uint32_t service_identifier
) __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_7_0
);
128 _dns_resolver_free (dns_create_resolver_t
*_resolver
) __OSX_AVAILABLE_STARTING(__MAC_10_4
,__IPHONE_2_0
);
130 #if !TARGET_OS_IPHONE
132 * DNS [resolver] flat-file configuration creation APIs
135 _dnsinfo_flatfile_add_resolvers (dns_create_config_t
*config
) __OSX_AVAILABLE_STARTING(__MAC_10_6
,__IPHONE_NA
);
138 _dnsinfo_flatfile_set_flags (uint32_t flags
) __OSX_AVAILABLE_STARTING(__MAC_10_9
,__IPHONE_NA
);
139 #endif // !TARGET_OS_IPHONE
143 #endif /* __DNSINFO_CREATE_H__ */