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