xref: /illumos-gate/usr/src/lib/smbsrv/libsmbns/common/smbns_dyndns.h (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SMBSRV_DYNDNS_H
27 #define	_SMBSRV_DYNDNS_H
28 
29 #include <smbsrv/libsmbns.h>
30 
31 /*
32  * Header section format:
33  *
34  * The header contains the following fields:
35  *
36  *                                     1  1  1  1  1  1
37  *       0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
38  *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
39  *     |                      ID                       |
40  *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
41  *     |QR|   Opcode  |AA|TC|RD|RA|   Z    |   RCODE   |
42  *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
43  *     |                    QDCOUNT                    |
44  *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
45  *     |                    ANCOUNT                    |
46  *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
47  *     |                    NSCOUNT                    |
48  *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
49  *     |                    ARCOUNT                    |
50  *     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
51  *
52  * where:
53  *
54  * ID              A 16 bit identifier assigned by the program that
55  *                 generates any kind of query.  This identifier is copied
56  *                 the corresponding reply and can be used by the requester
57  *                 to match up replies to outstanding queries.
58  *
59  * QR              A one bit field that specifies whether this message is a
60  *                 query (0), or a response (1).
61  *
62  * OPCODE          A four bit field that specifies kind of query in this
63  *                 message.  This value is set by the originator of a query
64  *                 and copied into the response.  The values are:
65  *
66  *                 0               a standard query (QUERY)
67  *
68  *                 1               an inverse query (IQUERY)
69  *
70  *                 2               a server status request (STATUS)
71  *
72  *                 3-15            reserved for future use
73  *
74  * AA              Authoritative Answer - this bit is valid in responses,
75  *                 and specifies that the responding name server is an
76  *                 authority for the domain name in question section.
77  *
78  *                 Note that the contents of the answer section may have
79  *                 multiple owner names because of aliases.  The AA bit
80  *
81  *                 corresponds to the name which matches the query name, or
82  *                 the first owner name in the answer section.
83  *
84  * TC              TrunCation - specifies that this message was truncated
85  *                 due to length greater than that permitted on the
86  *                 transmission channel.
87  *
88  * RD              Recursion Desired - this bit may be set in a query and
89  *                 is copied into the response.  If RD is set, it directs
90  *                 the name server to pursue the query recursively.
91  *                 Recursive query support is optional.
92  *
93  * RA              Recursion Available - this be is set or cleared in a
94  *                 response, and denotes whether recursive query support is
95  *                 available in the name server.
96  *
97  * Z               Reserved for future use.  Must be zero in all queries
98  *                 and responses.
99  *
100  * RCODE           Response code - this 4 bit field is set as part of
101  *                 responses.  The values have the following
102  *                 interpretation:
103  *
104  *                 0               No error condition
105  *
106  *                 1               Format error - The name server was
107  *                                 unable to interpret the query.
108  *
109  *                 2               Server failure - The name server was
110  *                                 unable to process this query due to a
111  *                                 problem with the name server.
112  *
113  *                 3               Name Error - Meaningful only for
114  *                                 responses from an authoritative name
115  *                                 server, this code signifies that the
116  *                                 domain name referenced in the query does
117  *                                 not exist.
118  *
119  *                 4               Not Implemented - The name server does
120  *                                 not support the requested kind of query.
121  *
122  *                 5               Refused - The name server refuses to
123  *                                 perform the specified operation for
124  *                                 policy reasons.  For example, a name
125  *                                 server may not wish to provide the
126  *                                 information to the particular requester,
127  *                                 or a name server may not wish to perform
128  *                                 a particular operation (e.g., zone
129  *
130  *                                 transfer) for particular data.
131  *
132  *                 6-15            Reserved for future use.
133  *
134  * QDCOUNT         an unsigned 16 bit integer specifying the number of
135  *                 entries in the question section.
136  *
137  * ANCOUNT         an unsigned 16 bit integer specifying the number of
138  *                 resource records in the answer section.
139  *
140  * NSCOUNT         an unsigned 16 bit integer specifying the number of name
141  *                 server resource records in the authority records
142  *                 section.
143  *
144  * ARCOUNT         an unsigned 16 bit integer specifying the number of
145  *                 resource records in the additional records section.
146  */
147 
148 #include <sys/types.h>
149 
150 #ifdef __cplusplus
151 extern "C" {
152 #endif
153 
154 /* Other definitions: */
155 #define	REQ_QUERY	1	/* DNS query request */
156 #define	REQ_UPDATE	0	/* DNS update request */
157 #define	UPDATE_FORW	1	/* Update forward lookup zone */
158 #define	UPDATE_REV	0	/* Update reverse lookup zone */
159 #define	UPDATE_ADD	1	/* Update add request */
160 #define	UPDATE_DEL	0	/* Update remove request */
161 #define	MODE_GSS_API	3	/* Key negotiation mode */
162 
163 /* Max buffer size for send and receive buffer */
164 #define	MAX_BUF_SIZE	2000
165 #define	MAX_RETRIES	3	/* Max number of send retries if no response */
166 #define	TSIG_SIGNED	1	/* TSIG contains signed data */
167 #define	TSIG_UNSIGNED	0	/* TSIG does not conain signed data */
168 #define	DNS_CHECK	1	/* Check DNS for entry */
169 #define	DNS_NOCHECK	0	/* Don't check DNS for entry */
170 #define	MAX_TCP_SIZE 	2000	/* max tcp DNS message size */
171 
172 /* Delete 1 entry */
173 #define	DEL_ONE		1
174 /* Delete all entries of the same resource name */
175 #define	DEL_ALL		0
176 
177 #define	DNSF_RECUR_SUPP 0x80    /* Server can do recursive queries */
178 #define	DNSF_RECUR_QRY  0x100   /* Query is recursive */
179 
180 #define	BUFLEN_TCP(x, y) (MAX_TCP_SIZE-(x-y))
181 #define	BUFLEN_UDP(x, y) (NS_PACKETSZ-(x-y))
182 
183 /*
184  * DDNS_TTL is the time to live in DNS caches. Note that this
185  * does not affect the entry in the authoritative DNS database.
186  */
187 #define	DDNS_TTL	1200
188 
189 #ifdef __cplusplus
190 }
191 #endif
192 
193 #endif /* _SMBSRV_DYNDNS_H */
194