genericopenlibs/cstdlib/LINCARPA/NAMESER.H
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /* NAMESER.H
       
     2  * 
       
     3  * Portions Copyright (c) 1993-1999 Nokia Corporation and/or its subsidiary(-ies).
       
     4  * All rights reserved.
       
     5  */
       
     6 
       
     7 /** @file
       
     8 @publishedAll
       
     9 @released
       
    10 */
       
    11 
       
    12 /*
       
    13  * Copyright (c) 1983, 1989, 1993
       
    14  *	The Regents of the University of California.  All rights reserved.
       
    15  *
       
    16  * Redistribution and use in source and binary forms, with or without
       
    17  * modification, are permitted provided that the following conditions
       
    18  * are met:
       
    19  * 1. Redistributions of source code must retain the above copyright
       
    20  *    notice, this list of conditions and the following disclaimer.
       
    21  * 2. Redistributions in binary form must reproduce the above copyright
       
    22  *    notice, this list of conditions and the following disclaimer in the
       
    23  *    documentation and/or other materials provided with the distribution.
       
    24  * 3. All advertising materials mentioning features or use of this software
       
    25  *    must display the following acknowledgement:
       
    26  *	This product includes software developed by the University of
       
    27  *	California, Berkeley and its contributors.
       
    28  * 4. Neither the name of the University nor the names of its contributors
       
    29  *    may be used to endorse or promote products derived from this software
       
    30  *    without specific prior written permission.
       
    31  *
       
    32  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
       
    33  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
       
    34  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
       
    35  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
       
    36  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
       
    37  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
       
    38  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
       
    39  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
       
    40  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
       
    41  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
       
    42  * SUCH DAMAGE.
       
    43  *
       
    44  * -
       
    45  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
       
    46  *
       
    47  * Permission to use, copy, modify, and distribute this software for any
       
    48  * purpose with or without fee is hereby granted, provided that the above
       
    49  * copyright notice and this permission notice appear in all copies, and that
       
    50  * the name of Digital Equipment Corporation not be used in advertising or
       
    51  * publicity pertaining to distribution of the document or software without
       
    52  * specific, written prior permission.
       
    53  *
       
    54  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
       
    55  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
       
    56  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
       
    57  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
       
    58  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
       
    59  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
       
    60  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
       
    61  * SOFTWARE.
       
    62  * -
       
    63  * Portions Copyright (c) 1995 by International Business Machines, Inc.
       
    64  *
       
    65  * International Business Machines, Inc. (hereinafter called IBM) grants
       
    66  * permission under its copyrights to use, copy, modify, and distribute this
       
    67  * Software with or without fee, provided that the above copyright notice and
       
    68  * all paragraphs of this notice appear in all copies, and that the name of IBM
       
    69  * not be used in connection with the marketing of any product incorporating
       
    70  * the Software or modifications thereof, without specific, written prior
       
    71  * permission.
       
    72  *
       
    73  * To the extent it has a right to do so, IBM grants an immunity from suit
       
    74  * under its patents, if any, for the use, sale or manufacture of products to
       
    75  * the extent that such products are used for performing Domain Name System
       
    76  * dynamic updates in TCP/IP networks by means of the Software.  No immunity is
       
    77  * granted for any product per se or for any other function of any product.
       
    78  * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
       
    79  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
       
    80  * PARTICULAR PURPOSE.  IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
       
    81  * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
       
    82  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
       
    83  * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
       
    84  *
       
    85  *      @(#)nameser.h	8.2 (Berkeley) 2/16/94
       
    86  *	From Id: nameser.h,v 8.11 1996/10/08 04:51:02 vixie Exp
       
    87  *	$Id: nameser.h,v 1.11 1997/02/23 09:17:20 peter Exp $
       
    88  */
       
    89 
       
    90 #ifndef _ARPA_NAMESER_H_
       
    91 #define	_ARPA_NAMESER_H_
       
    92 
       
    93 #ifdef __cplusplus
       
    94 extern "C" {
       
    95 #endif
       
    96 
       
    97 #include <sys/param.h>
       
    98 #include <sys/types.h>
       
    99 
       
   100 /**
       
   101 revision information.  this is the release date in YYYYMMDD format.
       
   102 it can change every day so the right thing to do with it is use it
       
   103 in preprocessor commands such as "#if (__BIND > 19931104)".  do not
       
   104 compare for equality; rather, use it to determine whether your resolver
       
   105 is new enough to contain a certain feature.
       
   106 */
       
   107 
       
   108 #define	__BIND		19960801	/* interface version stamp */
       
   109 
       
   110 /**
       
   111 Define constants based on rfc883
       
   112 */
       
   113 
       
   114 /** maximum packet size */
       
   115 #define	PACKETSZ	512		
       
   116 
       
   117 /** maximum presentation domain name */
       
   118 #define MAXDNAME	1025		
       
   119 
       
   120 /** maximum compressed domain name */
       
   121 #define	MAXCDNAME	255		
       
   122 
       
   123 /** maximum length of domain label */
       
   124 #define	MAXLABEL	63		
       
   125 
       
   126 /** #/bytes of fixed data in header */
       
   127 #define	HFIXEDSZ	12		
       
   128 
       
   129 /** #/bytes of fixed data in query */
       
   130 #define	QFIXEDSZ	4		
       
   131 
       
   132 /** #/bytes of fixed data in r record */
       
   133 #define	RRFIXEDSZ	10		
       
   134 
       
   135 /** for systems without 32-bit ints */
       
   136 #define	INT32SZ		4		
       
   137 
       
   138 /** for systems without 16-bit ints */
       
   139 #define	INT16SZ		2		
       
   140 
       
   141 /** IPv4 T_A */
       
   142 #define INADDRSZ	4		
       
   143 
       
   144 /** IPv6 T_AAAA */
       
   145 #define IN6ADDRSZ	16		
       
   146 
       
   147 /**
       
   148 Internet nameserver port number
       
   149 */
       
   150 #define	NAMESERVER_PORT	53
       
   151 
       
   152 
       
   153 /**
       
   154 Currently defined opcodes
       
   155 */
       
   156 
       
   157 /** standard query */
       
   158 #define	QUERY		0x0		
       
   159 
       
   160 	/** inverse query */
       
   161 #define	IQUERY		0x1	
       
   162 
       
   163 /** nameserver status query */
       
   164 #define	STATUS		0x2		
       
   165 
       
   166 /* 0x3 reserved */
       
   167 /*#define xxx		0x3 */
       
   168 #define	NS_NOTIFY_OP	0x4		/* notify secondary of SOA change */
       
   169 
       
   170 
       
   171 /**
       
   172 Currently defined response codes
       
   173 */
       
   174 
       
   175 /** no error */
       
   176 #define	NOERROR		0	
       
   177 
       
   178 /** format error */
       
   179 #define	FORMERR		1		
       
   180 
       
   181 /** server failure */
       
   182 #define	SERVFAIL	2		
       
   183 
       
   184 /** non existent domain */
       
   185 #define	NXDOMAIN	3		
       
   186 
       
   187 /** not implemented */
       
   188 #define	NOTIMP		4		
       
   189 
       
   190 /** query refused */
       
   191 #define	REFUSED		5		
       
   192 
       
   193 
       
   194 
       
   195 /**
       
   196 Type values for resources and queries
       
   197 */
       
   198 
       
   199 /** host address */
       
   200 #define	T_A		1		
       
   201 
       
   202 /** authoritative server */
       
   203 #define	T_NS		2		
       
   204 
       
   205 /** mail destination */
       
   206 #define	T_MD		3		
       
   207 
       
   208 /** mail forwarder */
       
   209 #define	T_MF		4	
       
   210 
       
   211 /** canonical name */
       
   212 #define T_CNAME		5		
       
   213 
       
   214 /** start of authority zone */
       
   215 #define	T_SOA		6		
       
   216 
       
   217 /** mailbox domain name */
       
   218 #define	T_MB		7		
       
   219 
       
   220 /** mail group member */
       
   221 #define	T_MG		8		
       
   222 
       
   223 /** mail rename name */
       
   224 #define	T_MR		9		
       
   225 
       
   226 /** null resource record */
       
   227 #define	T_NULL		10		
       
   228 
       
   229 /** well known service */
       
   230 #define	T_WKS		11		
       
   231 
       
   232 /** domain name pointer */
       
   233 #define	T_PTR		12		
       
   234 
       
   235 /** host information */
       
   236 #define	T_HINFO		13		
       
   237 
       
   238 /** mailbox information */
       
   239 #define	T_MINFO		14		
       
   240 
       
   241 /** mail routing information */
       
   242 #define	T_MX		15		
       
   243 
       
   244 /** text strings */
       
   245 #define	T_TXT		16		
       
   246 
       
   247 /** responsible person */
       
   248 #define	T_RP		17		
       
   249 
       
   250 /** AFS cell database */
       
   251 #define	T_AFSDB		18		
       
   252 
       
   253 /** X_25 calling address */
       
   254 #define	T_X25		19		
       
   255 
       
   256 /** ISDN calling address */
       
   257 #define	T_ISDN		20		
       
   258 
       
   259 /** router */
       
   260 #define	T_RT		21		
       
   261 
       
   262 /** NSAP address */
       
   263 #define	T_NSAP		22		
       
   264 
       
   265 /** reverse NSAP lookup (deprecated) */
       
   266 #define	T_NSAP_PTR	23		
       
   267 
       
   268 /** security signature */
       
   269 #define	T_SIG		24		
       
   270 
       
   271 /** security key */
       
   272 #define	T_KEY		25	
       
   273 
       
   274 /** X.400 mail mapping */
       
   275 #define	T_PX		26		
       
   276 
       
   277 /** geographical position (withdrawn) */
       
   278 #define	T_GPOS		27	
       
   279 
       
   280 /** IP6 Address */
       
   281 #define	T_AAAA		28		
       
   282 
       
   283 /** Location Information */
       
   284 #define	T_LOC		29		
       
   285 
       
   286 /** Next Valid Name in Zone */
       
   287 #define T_NXT		30		
       
   288 
       
   289 /** Endpoint identifier */
       
   290 #define T_EID		31		
       
   291 
       
   292 /** Nimrod locator */
       
   293 #define T_NIMLOC	32	
       
   294 
       
   295 /** Server selection */
       
   296 #define T_SRV		33		
       
   297 
       
   298 /** ATM Address */
       
   299 #define T_ATMA		34		
       
   300 
       
   301 /** Naming Authority PoinTeR */
       
   302 #define T_NAPTR		35		
       
   303 
       
   304 /** user (finger) information
       
   305 non standard 
       
   306 */
       
   307 #define	T_UINFO		100		
       
   308 
       
   309 /** user ID */
       
   310 #define	T_UID		101		
       
   311 
       
   312 /** group ID */
       
   313 #define	T_GID		102		
       
   314 
       
   315 /** Unspecified format (binary data) */
       
   316 #define	T_UNSPEC	103		
       
   317 
       
   318 /** Query type values which do not appear in resource records
       
   319 incremental zone transfer */
       
   320 #define T_IXFR		251		
       
   321 
       
   322 /** transfer zone of authority */
       
   323 #define	T_AXFR		252		
       
   324 
       
   325 /** transfer mailbox records */
       
   326 #define	T_MAILB		253		
       
   327 
       
   328 /** transfer mail agent records */
       
   329 #define	T_MAILA		254		
       
   330 
       
   331 /** wildcard match */
       
   332 #define	T_ANY		255		
       
   333 
       
   334 /**
       
   335 Values for class field
       
   336 */
       
   337 #define	C_IN		1		/* the arpa internet */
       
   338 #define	C_CHAOS		3		/* for chaos net (MIT) */
       
   339 #define	C_HS		4		/* for Hesiod name server (MIT) (XXX) */
       
   340 	/* Query class values which do not appear in resource records */
       
   341 #define	C_ANY		255		/* wildcard match */
       
   342 
       
   343 /**
       
   344 Flags field of the KEY RR rdata
       
   345 */
       
   346 #define	KEYFLAG_TYPEMASK	0xC000	/* Mask for "type" bits */
       
   347 #define	KEYFLAG_TYPE_AUTH_CONF	0x0000	/* Key usable for both */
       
   348 #define	KEYFLAG_TYPE_CONF_ONLY	0x8000	/* Key usable for confidentiality */
       
   349 #define	KEYFLAG_TYPE_AUTH_ONLY	0x4000	/* Key usable for authentication */
       
   350 #define	KEYFLAG_TYPE_NO_KEY	0xC000	/* No key usable for either; no key */
       
   351 /** The type bits can also be interpreted independently, as single bits: */
       
   352 #define	KEYFLAG_NO_AUTH		0x8000	/* Key not usable for authentication */
       
   353 #define	KEYFLAG_NO_CONF		0x4000	/* Key not usable for confidentiality */
       
   354 
       
   355 #define	KEYFLAG_EXPERIMENTAL	0x2000	/* Security is *mandatory* if bit=0 */
       
   356 #define	KEYFLAG_RESERVED3	0x1000  /* reserved - must be zero */
       
   357 #define	KEYFLAG_RESERVED4	0x0800  /* reserved - must be zero */
       
   358 #define	KEYFLAG_USERACCOUNT	0x0400	/* key is assoc. with a user acct */
       
   359 #define	KEYFLAG_ENTITY		0x0200	/* key is assoc. with entity eg host */
       
   360 #define	KEYFLAG_ZONEKEY		0x0100	/* key is zone key for the zone named */
       
   361 #define	KEYFLAG_IPSEC		0x0080  /* key is for IPSEC use (host or user)*/
       
   362 #define	KEYFLAG_EMAIL		0x0040  /* key is for email (MIME security) */
       
   363 #define	KEYFLAG_RESERVED10	0x0020  /* reserved - must be zero */
       
   364 #define	KEYFLAG_RESERVED11	0x0010  /* reserved - must be zero */
       
   365 #define	KEYFLAG_SIGNATORYMASK	0x000F	/* key can sign DNS RR's of same name */
       
   366 
       
   367 #define  KEYFLAG_RESERVED_BITMASK ( KEYFLAG_RESERVED3 | \
       
   368 				    KEYFLAG_RESERVED4 | \
       
   369 				    KEYFLAG_RESERVED10| KEYFLAG_RESERVED11) 
       
   370 
       
   371 /**
       
   372 The Algorithm field of the KEY and SIG RR's is an integer, {1..254} 
       
   373 */
       
   374 #define	ALGORITHM_MD5RSA	1	/* MD5 with RSA */
       
   375 #define	ALGORITHM_EXPIRE_ONLY	253	/* No alg, no security */
       
   376 #define	ALGORITHM_PRIVATE_OID	254	/* Key begins with OID indicating alg */
       
   377 
       
   378 /**
       
   379 Signatures 
       
   380 */
       
   381 					/** Size of a mod or exp in bits */
       
   382 #define	MIN_MD5RSA_KEY_PART_BITS	 512
       
   383 #define	MAX_MD5RSA_KEY_PART_BITS	2552
       
   384 					/** Total of binary mod and exp, bytes */
       
   385 #define	MAX_MD5RSA_KEY_BYTES		((MAX_MD5RSA_KEY_PART_BITS+7/8)*2+3)
       
   386 					/** Max length of text sig block */
       
   387 #define	MAX_KEY_BASE64			(((MAX_MD5RSA_KEY_BYTES+2)/3)*4)
       
   388 
       
   389 /**
       
   390 Status return codes for T_UNSPEC conversion routines
       
   391 */
       
   392 #define	CONV_SUCCESS	0
       
   393 #define	CONV_OVERFLOW	(-1)
       
   394 #define	CONV_BADFMT	(-2)
       
   395 #define	CONV_BADCKSUM	(-3)
       
   396 #define	CONV_BADBUFLEN	(-4)
       
   397 
       
   398 /**
       
   399 Structure for query header.  The order of the fields is machine- and
       
   400 compiler-dependent, depending on the byte/bit order and the layout
       
   401 of bit fields.  We use bit fields only in int variables, as this
       
   402 is all ANSI requires.  This requires a somewhat confusing rearrangement.
       
   403 EPOC32 is little-endian
       
   404 */
       
   405 typedef struct {
       
   406 	unsigned	id :16;		/* query identification number */
       
   407 			/* fields in third byte */
       
   408 	unsigned	rd :1;		/* recursion desired */
       
   409 	unsigned	tc :1;		/* truncated message */
       
   410 	unsigned	aa :1;		/* authoritative answer */
       
   411 	unsigned	opcode :4;	/* purpose of message */
       
   412 	unsigned	qr :1;		/* response flag */
       
   413 			/* fields in fourth byte */
       
   414 	unsigned	rcode :4;	/* response code */
       
   415 	unsigned	cd: 1;		/* checking disabled by resolver */
       
   416 	unsigned	ad: 1;		/* authentic data from named */
       
   417 	unsigned	unused :1;	/* unused bits (MBZ as of 4.9.3a3) */
       
   418 	unsigned	ra :1;		/* recursion available */
       
   419 			/* remaining bytes */
       
   420 	unsigned	qdcount :16;	/* number of question entries */
       
   421 	unsigned	ancount :16;	/* number of answer entries */
       
   422 	unsigned	nscount :16;	/* number of authority entries */
       
   423 	unsigned	arcount :16;	/* number of resource entries */
       
   424 } HEADER;
       
   425 
       
   426 /**
       
   427 Defines for handling compressed domain names
       
   428 */
       
   429 #define	INDIR_MASK	0xc0
       
   430 
       
   431 extern	u_int16_t	_getshort (const u_char *);
       
   432 extern	u_int32_t	_getlong (const u_char *);
       
   433 
       
   434 /**
       
   435 Inline versions of get/put short/long.  Pointer is advanced.
       
   436 
       
   437 These macros demonstrate the property of C whereby it can be
       
   438 portable or it can be elegant but rarely both.
       
   439 */
       
   440 #define	GETSHORT(s, cp) { \
       
   441 	register u_char *t_cp = (u_char *)(cp); \
       
   442 	(s) = ((u_int16_t)t_cp[0] << 8) \
       
   443 	    | ((u_int16_t)t_cp[1]) \
       
   444 	    ; \
       
   445 	(cp) += INT16SZ; \
       
   446 }
       
   447 
       
   448 #define	GETLONG(l, cp) { \
       
   449 	register u_char *t_cp = (u_char *)(cp); \
       
   450 	(l) = ((u_int32_t)t_cp[0] << 24) \
       
   451 	    | ((u_int32_t)t_cp[1] << 16) \
       
   452 	    | ((u_int32_t)t_cp[2] << 8) \
       
   453 	    | ((u_int32_t)t_cp[3]) \
       
   454 	    ; \
       
   455 	(cp) += INT32SZ; \
       
   456 }
       
   457 
       
   458 #define	PUTSHORT(s, cp) { \
       
   459 	register u_int16_t t_s = (u_int16_t)(s); \
       
   460 	register u_char *t_cp = (u_char *)(cp); \
       
   461 	*t_cp++ = t_s >> 8; \
       
   462 	*t_cp   = t_s; \
       
   463 	(cp) += INT16SZ; \
       
   464 }
       
   465 
       
   466 #define	PUTLONG(l, cp) { \
       
   467 	register u_int32_t t_l = (u_int32_t)(l); \
       
   468 	register u_char *t_cp = (u_char *)(cp); \
       
   469 	*t_cp++ = t_l >> 24; \
       
   470 	*t_cp++ = t_l >> 16; \
       
   471 	*t_cp++ = t_l >> 8; \
       
   472 	*t_cp   = t_l; \
       
   473 	(cp) += INT32SZ; \
       
   474 }
       
   475 
       
   476 #ifdef __cplusplus
       
   477 }
       
   478 #endif
       
   479 #endif /* !_ARPA_NAMESER_H_ */