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