]> git.saurik.com Git - apple/configd.git/blob - dnsinfo/dnsinfo_private.h
configd-204.tar.gz
[apple/configd.git] / dnsinfo / dnsinfo_private.h
1 /*
2 * Copyright (c) 2004-2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #ifndef __DNSINFO_PRIVATE_H__
25 #define __DNSINFO_PRIVATE_H__
26
27
28 #include <AvailabilityMacros.h>
29 #include <sys/cdefs.h>
30 #include <stdint.h>
31 #include <sys/types.h>
32 #include <sys/socket.h>
33 #include <netinet/in.h>
34 #include <mach/mach.h>
35
36 #include "dnsinfo.h"
37
38 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
39
40 /*
41 * What's all of this stuff about???
42 *
43 * In order to minimize the amount of data conversions associated with
44 * storing, retrieving, and accessing the systems DNS configuration I
45 * have opted to create a memory image filled with the actual data
46 * types / structures that would be used by those applications which
47 * make use of these APIS. The implication here is that we use
48 * sockaddr's for addresses, char *'s for strings, etc.
49 *
50 * To achieve this goal the APIs which are used to store and access the
51 * configuration data build and use a single buffer of the relevant
52 * bits. When multiple instances of a given type / structure are needed
53 * we maintain a count, the actual data, and when the configuration has
54 * been unpacked, arrays of pointers to the data.
55 *
56 * In memory, the data looks as follows:
57 *
58 * +-------------------------------------------------------------------+
59 * | struct _dns_config_buf_t |
60 * +-+-------------+---------------------------------------------------+
61 * | | config | struct dns_config_t |
62 * | | +-+--------------+----------------------------------+
63 * | | | | n_resolver | int32_t | <- # of name resolvers
64 * | | | +--------------+----------------------------------+
65 * | | | | resolver | dns_resolver_t ** | <- not used during creation, filled
66 * | | | | | | in with pointer to a list of
67 * | | | | | | resolver configurations which be
68 * | | | | | | established in the "padding"
69 * | | | +--------------+----------------------------------+
70 * | | | | ... | ... |
71 * | +-------------+-+--------------+----------------------------------+
72 * | | n_attribute | uint32_t | <- how many bytes of "attribute"
73 * | | | | data is associated with the
74 * | | | | configuration
75 * |-+-------------+---------------------------------------------------+
76 * | | n_padding | uint32_t | <- how many additional bytes
77 * | | | | for arrays (of pointers), ...
78 * +-+-------------+---------------------------------------------------+
79 * | struct dns_attribute_t |
80 * |-+-------------+---------------------------------------------------+
81 * | | type | uint32_t | <- type of attribute (e.g. CONFIG_ATTRIBUTE_RESOLVER)
82 * | +-------------+---------------------------------------------------+
83 * | | length | uint32_t | <- length of the attribute
84 * | +-------------+---------------------------------------------------+
85 * | | attribute | struct _dns_resolver_buf_t | <- the attribute data (resolver configuration #1)
86 * | | +-+-------------+-----------------------------------+
87 * | | | | resolver | struct dns_resolver_t |
88 * | | | | +--------------+--------------------+
89 * | | | | | domain | char * | <- not used during creation,
90 * | | | | | | | filled in with pointer to
91 * | | | | | | | domain name in the "padding"
92 * | | | | +--------------+--------------------+
93 * | | | | | n_nameserver | int32_t | <- # of name server addresses
94 * | | | | +--------------+--------------------+
95 * | | | | | nameserver | struct sockaddr ** | <- not used during creation,
96 * | | | | | | | filled in with pointer to
97 * | | | | | | | a list of addresses which
98 * | | | | | | | will be established in the
99 * | | | | | | | "padding"
100 * | | | | +--------------+--------------------+
101 * | | | | | ... |
102 * | | +-+-------------+--------------+--------------------+
103 * | | | | n_attribute | uint32_t |
104 * | | +-+-------------+-----------------------------------+
105 * | | | | attribute | struct dns_attribute_t |
106 * | | | | +-+-----------+---------------------+
107 * | | | | | | type | uint32_t | <- type of attribute (e.g. RESOLVER_ATTRIBUTE_DOMAIN)
108 * | | | | | +-----------+---------------------+
109 * | | | | | | length | uint32_t | <- length of the attribute
110 * | | | | | +-----------+---------------------+
111 * | | | | | | attribute | | <- the attribute data ("apple.com")
112 * | | +-+-------------+-------------+---------------------+
113 * | | | | attribute | struct dns_attribute_t |
114 * | | | | +-+-----------+---------------------+
115 * | | | | | | type | uint32_t | <- type of attribute (e.g. RESOLVER_ATTRIBUTE_ADDRESS)
116 * | | | | | +-----------+---------------------+
117 * | | | | | | length | uint32_t | <- length of the attribute
118 * | | | | | +-----------+---------------------+
119 * | | | | | | attribute | | <- the attribute data ("struct sockaddr_in" #1)
120 * | | +---------------+-----------------------------------+
121 * | | | | attribute | struct dns_attribute_t |
122 * | | | | +-+-----------+---------------------+
123 * | | | | | | type | uint32_t | <- type of attribute (e.g. RESOLVER_ATTRIBUTE_ADDRESS)
124 * | | | | | +-----------+---------------------+
125 * | | | | | | length | uint32_t | <- length of the attribute
126 * | | | | | +-----------+---------------------+
127 * | | | | | | attribute | | <- the attribute data ("struct sockaddr_in" #2)
128 * | | +---------------+-----------------------------------+
129 * | | | ... |
130 * +-+-------------+---------------------------------------------------+
131 * | | attribute | struct _dns_resolver_buf_t | <- the attribute data (resolver configuration #2)
132 * | | +---------------+-----------------------------------+
133 * | | | ... |
134 * +---------------+---------------------------------------------------+
135 * | | ... |
136 * +---------------+---------------------------------------------------+
137 *
138 * When the data is unpacked the "n_padding" additional bytes
139 * specified in configuration buffer will be allocated at the
140 * end of this buffer. Arrays of pointers will be allocated
141 * within the extra space array element (an "attribute") is
142 * encountered the pointer reference will be filled in.
143 */
144
145
146 // configuration buffer attributes
147 enum {
148 CONFIG_ATTRIBUTE_RESOLVER = 1
149 };
150
151
152 // resolver buffer attributes
153 enum {
154 RESOLVER_ATTRIBUTE_DOMAIN = 10,
155 RESOLVER_ATTRIBUTE_ADDRESS,
156 RESOLVER_ATTRIBUTE_SEARCH,
157 RESOLVER_ATTRIBUTE_SORTADDR,
158 RESOLVER_ATTRIBUTE_OPTIONS
159 };
160
161
162 #pragma pack(4)
163 typedef struct {
164 uint32_t type;
165 uint32_t length;
166 uint8_t attribute[0];
167 } dns_attribute_t;
168 #pragma pack()
169
170
171 #pragma pack(4)
172 typedef struct {
173 dns_config_t config;
174 uint32_t n_attribute;
175 uint32_t n_padding;
176 uint8_t attribute[0];
177 } _dns_config_buf_t;
178 #pragma pack()
179
180
181 #pragma pack(4)
182 typedef struct {
183 dns_resolver_t resolver;
184 uint32_t n_attribute;
185 uint8_t attribute[0];
186 } _dns_resolver_buf_t;
187 #pragma pack()
188
189
190 __BEGIN_DECLS
191
192 const char * _dns_configuration_notify_key (void) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
193 mach_port_t _dns_configuration_server_port (void) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
194
195 __END_DECLS
196
197 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 */
198
199 #endif /* __DNSINFO_PRIVATE_H__ */