os/ossrv/genericopenlibs/cstdlib/LINCARPA/NAMESER.H
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LINCARPA/NAMESER.H	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,479 @@
     1.4 +/* NAMESER.H
     1.5 + * 
     1.6 + * Portions Copyright (c) 1993-1999 Nokia Corporation and/or its subsidiary(-ies).
     1.7 + * All rights reserved.
     1.8 + */
     1.9 +
    1.10 +/** @file
    1.11 +@publishedAll
    1.12 +@released
    1.13 +*/
    1.14 +
    1.15 +/*
    1.16 + * Copyright (c) 1983, 1989, 1993
    1.17 + *	The Regents of the University of California.  All rights reserved.
    1.18 + *
    1.19 + * Redistribution and use in source and binary forms, with or without
    1.20 + * modification, are permitted provided that the following conditions
    1.21 + * are met:
    1.22 + * 1. Redistributions of source code must retain the above copyright
    1.23 + *    notice, this list of conditions and the following disclaimer.
    1.24 + * 2. Redistributions in binary form must reproduce the above copyright
    1.25 + *    notice, this list of conditions and the following disclaimer in the
    1.26 + *    documentation and/or other materials provided with the distribution.
    1.27 + * 3. All advertising materials mentioning features or use of this software
    1.28 + *    must display the following acknowledgement:
    1.29 + *	This product includes software developed by the University of
    1.30 + *	California, Berkeley and its contributors.
    1.31 + * 4. Neither the name of the University nor the names of its contributors
    1.32 + *    may be used to endorse or promote products derived from this software
    1.33 + *    without specific prior written permission.
    1.34 + *
    1.35 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    1.36 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.37 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.38 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
    1.39 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    1.40 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    1.41 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    1.42 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    1.43 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    1.44 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.45 + * SUCH DAMAGE.
    1.46 + *
    1.47 + * -
    1.48 + * Portions Copyright (c) 1993 by Digital Equipment Corporation.
    1.49 + *
    1.50 + * Permission to use, copy, modify, and distribute this software for any
    1.51 + * purpose with or without fee is hereby granted, provided that the above
    1.52 + * copyright notice and this permission notice appear in all copies, and that
    1.53 + * the name of Digital Equipment Corporation not be used in advertising or
    1.54 + * publicity pertaining to distribution of the document or software without
    1.55 + * specific, written prior permission.
    1.56 + *
    1.57 + * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
    1.58 + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
    1.59 + * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
    1.60 + * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
    1.61 + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
    1.62 + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
    1.63 + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
    1.64 + * SOFTWARE.
    1.65 + * -
    1.66 + * Portions Copyright (c) 1995 by International Business Machines, Inc.
    1.67 + *
    1.68 + * International Business Machines, Inc. (hereinafter called IBM) grants
    1.69 + * permission under its copyrights to use, copy, modify, and distribute this
    1.70 + * Software with or without fee, provided that the above copyright notice and
    1.71 + * all paragraphs of this notice appear in all copies, and that the name of IBM
    1.72 + * not be used in connection with the marketing of any product incorporating
    1.73 + * the Software or modifications thereof, without specific, written prior
    1.74 + * permission.
    1.75 + *
    1.76 + * To the extent it has a right to do so, IBM grants an immunity from suit
    1.77 + * under its patents, if any, for the use, sale or manufacture of products to
    1.78 + * the extent that such products are used for performing Domain Name System
    1.79 + * dynamic updates in TCP/IP networks by means of the Software.  No immunity is
    1.80 + * granted for any product per se or for any other function of any product.
    1.81 + * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
    1.82 + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
    1.83 + * PARTICULAR PURPOSE.  IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
    1.84 + * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
    1.85 + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
    1.86 + * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
    1.87 + *
    1.88 + *      @(#)nameser.h	8.2 (Berkeley) 2/16/94
    1.89 + *	From Id: nameser.h,v 8.11 1996/10/08 04:51:02 vixie Exp
    1.90 + *	$Id: nameser.h,v 1.11 1997/02/23 09:17:20 peter Exp $
    1.91 + */
    1.92 +
    1.93 +#ifndef _ARPA_NAMESER_H_
    1.94 +#define	_ARPA_NAMESER_H_
    1.95 +
    1.96 +#ifdef __cplusplus
    1.97 +extern "C" {
    1.98 +#endif
    1.99 +
   1.100 +#include <sys/param.h>
   1.101 +#include <sys/types.h>
   1.102 +
   1.103 +/**
   1.104 +revision information.  this is the release date in YYYYMMDD format.
   1.105 +it can change every day so the right thing to do with it is use it
   1.106 +in preprocessor commands such as "#if (__BIND > 19931104)".  do not
   1.107 +compare for equality; rather, use it to determine whether your resolver
   1.108 +is new enough to contain a certain feature.
   1.109 +*/
   1.110 +
   1.111 +#define	__BIND		19960801	/* interface version stamp */
   1.112 +
   1.113 +/**
   1.114 +Define constants based on rfc883
   1.115 +*/
   1.116 +
   1.117 +/** maximum packet size */
   1.118 +#define	PACKETSZ	512		
   1.119 +
   1.120 +/** maximum presentation domain name */
   1.121 +#define MAXDNAME	1025		
   1.122 +
   1.123 +/** maximum compressed domain name */
   1.124 +#define	MAXCDNAME	255		
   1.125 +
   1.126 +/** maximum length of domain label */
   1.127 +#define	MAXLABEL	63		
   1.128 +
   1.129 +/** #/bytes of fixed data in header */
   1.130 +#define	HFIXEDSZ	12		
   1.131 +
   1.132 +/** #/bytes of fixed data in query */
   1.133 +#define	QFIXEDSZ	4		
   1.134 +
   1.135 +/** #/bytes of fixed data in r record */
   1.136 +#define	RRFIXEDSZ	10		
   1.137 +
   1.138 +/** for systems without 32-bit ints */
   1.139 +#define	INT32SZ		4		
   1.140 +
   1.141 +/** for systems without 16-bit ints */
   1.142 +#define	INT16SZ		2		
   1.143 +
   1.144 +/** IPv4 T_A */
   1.145 +#define INADDRSZ	4		
   1.146 +
   1.147 +/** IPv6 T_AAAA */
   1.148 +#define IN6ADDRSZ	16		
   1.149 +
   1.150 +/**
   1.151 +Internet nameserver port number
   1.152 +*/
   1.153 +#define	NAMESERVER_PORT	53
   1.154 +
   1.155 +
   1.156 +/**
   1.157 +Currently defined opcodes
   1.158 +*/
   1.159 +
   1.160 +/** standard query */
   1.161 +#define	QUERY		0x0		
   1.162 +
   1.163 +	/** inverse query */
   1.164 +#define	IQUERY		0x1	
   1.165 +
   1.166 +/** nameserver status query */
   1.167 +#define	STATUS		0x2		
   1.168 +
   1.169 +/* 0x3 reserved */
   1.170 +/*#define xxx		0x3 */
   1.171 +#define	NS_NOTIFY_OP	0x4		/* notify secondary of SOA change */
   1.172 +
   1.173 +
   1.174 +/**
   1.175 +Currently defined response codes
   1.176 +*/
   1.177 +
   1.178 +/** no error */
   1.179 +#define	NOERROR		0	
   1.180 +
   1.181 +/** format error */
   1.182 +#define	FORMERR		1		
   1.183 +
   1.184 +/** server failure */
   1.185 +#define	SERVFAIL	2		
   1.186 +
   1.187 +/** non existent domain */
   1.188 +#define	NXDOMAIN	3		
   1.189 +
   1.190 +/** not implemented */
   1.191 +#define	NOTIMP		4		
   1.192 +
   1.193 +/** query refused */
   1.194 +#define	REFUSED		5		
   1.195 +
   1.196 +
   1.197 +
   1.198 +/**
   1.199 +Type values for resources and queries
   1.200 +*/
   1.201 +
   1.202 +/** host address */
   1.203 +#define	T_A		1		
   1.204 +
   1.205 +/** authoritative server */
   1.206 +#define	T_NS		2		
   1.207 +
   1.208 +/** mail destination */
   1.209 +#define	T_MD		3		
   1.210 +
   1.211 +/** mail forwarder */
   1.212 +#define	T_MF		4	
   1.213 +
   1.214 +/** canonical name */
   1.215 +#define T_CNAME		5		
   1.216 +
   1.217 +/** start of authority zone */
   1.218 +#define	T_SOA		6		
   1.219 +
   1.220 +/** mailbox domain name */
   1.221 +#define	T_MB		7		
   1.222 +
   1.223 +/** mail group member */
   1.224 +#define	T_MG		8		
   1.225 +
   1.226 +/** mail rename name */
   1.227 +#define	T_MR		9		
   1.228 +
   1.229 +/** null resource record */
   1.230 +#define	T_NULL		10		
   1.231 +
   1.232 +/** well known service */
   1.233 +#define	T_WKS		11		
   1.234 +
   1.235 +/** domain name pointer */
   1.236 +#define	T_PTR		12		
   1.237 +
   1.238 +/** host information */
   1.239 +#define	T_HINFO		13		
   1.240 +
   1.241 +/** mailbox information */
   1.242 +#define	T_MINFO		14		
   1.243 +
   1.244 +/** mail routing information */
   1.245 +#define	T_MX		15		
   1.246 +
   1.247 +/** text strings */
   1.248 +#define	T_TXT		16		
   1.249 +
   1.250 +/** responsible person */
   1.251 +#define	T_RP		17		
   1.252 +
   1.253 +/** AFS cell database */
   1.254 +#define	T_AFSDB		18		
   1.255 +
   1.256 +/** X_25 calling address */
   1.257 +#define	T_X25		19		
   1.258 +
   1.259 +/** ISDN calling address */
   1.260 +#define	T_ISDN		20		
   1.261 +
   1.262 +/** router */
   1.263 +#define	T_RT		21		
   1.264 +
   1.265 +/** NSAP address */
   1.266 +#define	T_NSAP		22		
   1.267 +
   1.268 +/** reverse NSAP lookup (deprecated) */
   1.269 +#define	T_NSAP_PTR	23		
   1.270 +
   1.271 +/** security signature */
   1.272 +#define	T_SIG		24		
   1.273 +
   1.274 +/** security key */
   1.275 +#define	T_KEY		25	
   1.276 +
   1.277 +/** X.400 mail mapping */
   1.278 +#define	T_PX		26		
   1.279 +
   1.280 +/** geographical position (withdrawn) */
   1.281 +#define	T_GPOS		27	
   1.282 +
   1.283 +/** IP6 Address */
   1.284 +#define	T_AAAA		28		
   1.285 +
   1.286 +/** Location Information */
   1.287 +#define	T_LOC		29		
   1.288 +
   1.289 +/** Next Valid Name in Zone */
   1.290 +#define T_NXT		30		
   1.291 +
   1.292 +/** Endpoint identifier */
   1.293 +#define T_EID		31		
   1.294 +
   1.295 +/** Nimrod locator */
   1.296 +#define T_NIMLOC	32	
   1.297 +
   1.298 +/** Server selection */
   1.299 +#define T_SRV		33		
   1.300 +
   1.301 +/** ATM Address */
   1.302 +#define T_ATMA		34		
   1.303 +
   1.304 +/** Naming Authority PoinTeR */
   1.305 +#define T_NAPTR		35		
   1.306 +
   1.307 +/** user (finger) information
   1.308 +non standard 
   1.309 +*/
   1.310 +#define	T_UINFO		100		
   1.311 +
   1.312 +/** user ID */
   1.313 +#define	T_UID		101		
   1.314 +
   1.315 +/** group ID */
   1.316 +#define	T_GID		102		
   1.317 +
   1.318 +/** Unspecified format (binary data) */
   1.319 +#define	T_UNSPEC	103		
   1.320 +
   1.321 +/** Query type values which do not appear in resource records
   1.322 +incremental zone transfer */
   1.323 +#define T_IXFR		251		
   1.324 +
   1.325 +/** transfer zone of authority */
   1.326 +#define	T_AXFR		252		
   1.327 +
   1.328 +/** transfer mailbox records */
   1.329 +#define	T_MAILB		253		
   1.330 +
   1.331 +/** transfer mail agent records */
   1.332 +#define	T_MAILA		254		
   1.333 +
   1.334 +/** wildcard match */
   1.335 +#define	T_ANY		255		
   1.336 +
   1.337 +/**
   1.338 +Values for class field
   1.339 +*/
   1.340 +#define	C_IN		1		/* the arpa internet */
   1.341 +#define	C_CHAOS		3		/* for chaos net (MIT) */
   1.342 +#define	C_HS		4		/* for Hesiod name server (MIT) (XXX) */
   1.343 +	/* Query class values which do not appear in resource records */
   1.344 +#define	C_ANY		255		/* wildcard match */
   1.345 +
   1.346 +/**
   1.347 +Flags field of the KEY RR rdata
   1.348 +*/
   1.349 +#define	KEYFLAG_TYPEMASK	0xC000	/* Mask for "type" bits */
   1.350 +#define	KEYFLAG_TYPE_AUTH_CONF	0x0000	/* Key usable for both */
   1.351 +#define	KEYFLAG_TYPE_CONF_ONLY	0x8000	/* Key usable for confidentiality */
   1.352 +#define	KEYFLAG_TYPE_AUTH_ONLY	0x4000	/* Key usable for authentication */
   1.353 +#define	KEYFLAG_TYPE_NO_KEY	0xC000	/* No key usable for either; no key */
   1.354 +/** The type bits can also be interpreted independently, as single bits: */
   1.355 +#define	KEYFLAG_NO_AUTH		0x8000	/* Key not usable for authentication */
   1.356 +#define	KEYFLAG_NO_CONF		0x4000	/* Key not usable for confidentiality */
   1.357 +
   1.358 +#define	KEYFLAG_EXPERIMENTAL	0x2000	/* Security is *mandatory* if bit=0 */
   1.359 +#define	KEYFLAG_RESERVED3	0x1000  /* reserved - must be zero */
   1.360 +#define	KEYFLAG_RESERVED4	0x0800  /* reserved - must be zero */
   1.361 +#define	KEYFLAG_USERACCOUNT	0x0400	/* key is assoc. with a user acct */
   1.362 +#define	KEYFLAG_ENTITY		0x0200	/* key is assoc. with entity eg host */
   1.363 +#define	KEYFLAG_ZONEKEY		0x0100	/* key is zone key for the zone named */
   1.364 +#define	KEYFLAG_IPSEC		0x0080  /* key is for IPSEC use (host or user)*/
   1.365 +#define	KEYFLAG_EMAIL		0x0040  /* key is for email (MIME security) */
   1.366 +#define	KEYFLAG_RESERVED10	0x0020  /* reserved - must be zero */
   1.367 +#define	KEYFLAG_RESERVED11	0x0010  /* reserved - must be zero */
   1.368 +#define	KEYFLAG_SIGNATORYMASK	0x000F	/* key can sign DNS RR's of same name */
   1.369 +
   1.370 +#define  KEYFLAG_RESERVED_BITMASK ( KEYFLAG_RESERVED3 | \
   1.371 +				    KEYFLAG_RESERVED4 | \
   1.372 +				    KEYFLAG_RESERVED10| KEYFLAG_RESERVED11) 
   1.373 +
   1.374 +/**
   1.375 +The Algorithm field of the KEY and SIG RR's is an integer, {1..254} 
   1.376 +*/
   1.377 +#define	ALGORITHM_MD5RSA	1	/* MD5 with RSA */
   1.378 +#define	ALGORITHM_EXPIRE_ONLY	253	/* No alg, no security */
   1.379 +#define	ALGORITHM_PRIVATE_OID	254	/* Key begins with OID indicating alg */
   1.380 +
   1.381 +/**
   1.382 +Signatures 
   1.383 +*/
   1.384 +					/** Size of a mod or exp in bits */
   1.385 +#define	MIN_MD5RSA_KEY_PART_BITS	 512
   1.386 +#define	MAX_MD5RSA_KEY_PART_BITS	2552
   1.387 +					/** Total of binary mod and exp, bytes */
   1.388 +#define	MAX_MD5RSA_KEY_BYTES		((MAX_MD5RSA_KEY_PART_BITS+7/8)*2+3)
   1.389 +					/** Max length of text sig block */
   1.390 +#define	MAX_KEY_BASE64			(((MAX_MD5RSA_KEY_BYTES+2)/3)*4)
   1.391 +
   1.392 +/**
   1.393 +Status return codes for T_UNSPEC conversion routines
   1.394 +*/
   1.395 +#define	CONV_SUCCESS	0
   1.396 +#define	CONV_OVERFLOW	(-1)
   1.397 +#define	CONV_BADFMT	(-2)
   1.398 +#define	CONV_BADCKSUM	(-3)
   1.399 +#define	CONV_BADBUFLEN	(-4)
   1.400 +
   1.401 +/**
   1.402 +Structure for query header.  The order of the fields is machine- and
   1.403 +compiler-dependent, depending on the byte/bit order and the layout
   1.404 +of bit fields.  We use bit fields only in int variables, as this
   1.405 +is all ANSI requires.  This requires a somewhat confusing rearrangement.
   1.406 +EPOC32 is little-endian
   1.407 +*/
   1.408 +typedef struct {
   1.409 +	unsigned	id :16;		/* query identification number */
   1.410 +			/* fields in third byte */
   1.411 +	unsigned	rd :1;		/* recursion desired */
   1.412 +	unsigned	tc :1;		/* truncated message */
   1.413 +	unsigned	aa :1;		/* authoritative answer */
   1.414 +	unsigned	opcode :4;	/* purpose of message */
   1.415 +	unsigned	qr :1;		/* response flag */
   1.416 +			/* fields in fourth byte */
   1.417 +	unsigned	rcode :4;	/* response code */
   1.418 +	unsigned	cd: 1;		/* checking disabled by resolver */
   1.419 +	unsigned	ad: 1;		/* authentic data from named */
   1.420 +	unsigned	unused :1;	/* unused bits (MBZ as of 4.9.3a3) */
   1.421 +	unsigned	ra :1;		/* recursion available */
   1.422 +			/* remaining bytes */
   1.423 +	unsigned	qdcount :16;	/* number of question entries */
   1.424 +	unsigned	ancount :16;	/* number of answer entries */
   1.425 +	unsigned	nscount :16;	/* number of authority entries */
   1.426 +	unsigned	arcount :16;	/* number of resource entries */
   1.427 +} HEADER;
   1.428 +
   1.429 +/**
   1.430 +Defines for handling compressed domain names
   1.431 +*/
   1.432 +#define	INDIR_MASK	0xc0
   1.433 +
   1.434 +extern	u_int16_t	_getshort (const u_char *);
   1.435 +extern	u_int32_t	_getlong (const u_char *);
   1.436 +
   1.437 +/**
   1.438 +Inline versions of get/put short/long.  Pointer is advanced.
   1.439 +
   1.440 +These macros demonstrate the property of C whereby it can be
   1.441 +portable or it can be elegant but rarely both.
   1.442 +*/
   1.443 +#define	GETSHORT(s, cp) { \
   1.444 +	register u_char *t_cp = (u_char *)(cp); \
   1.445 +	(s) = ((u_int16_t)t_cp[0] << 8) \
   1.446 +	    | ((u_int16_t)t_cp[1]) \
   1.447 +	    ; \
   1.448 +	(cp) += INT16SZ; \
   1.449 +}
   1.450 +
   1.451 +#define	GETLONG(l, cp) { \
   1.452 +	register u_char *t_cp = (u_char *)(cp); \
   1.453 +	(l) = ((u_int32_t)t_cp[0] << 24) \
   1.454 +	    | ((u_int32_t)t_cp[1] << 16) \
   1.455 +	    | ((u_int32_t)t_cp[2] << 8) \
   1.456 +	    | ((u_int32_t)t_cp[3]) \
   1.457 +	    ; \
   1.458 +	(cp) += INT32SZ; \
   1.459 +}
   1.460 +
   1.461 +#define	PUTSHORT(s, cp) { \
   1.462 +	register u_int16_t t_s = (u_int16_t)(s); \
   1.463 +	register u_char *t_cp = (u_char *)(cp); \
   1.464 +	*t_cp++ = t_s >> 8; \
   1.465 +	*t_cp   = t_s; \
   1.466 +	(cp) += INT16SZ; \
   1.467 +}
   1.468 +
   1.469 +#define	PUTLONG(l, cp) { \
   1.470 +	register u_int32_t t_l = (u_int32_t)(l); \
   1.471 +	register u_char *t_cp = (u_char *)(cp); \
   1.472 +	*t_cp++ = t_l >> 24; \
   1.473 +	*t_cp++ = t_l >> 16; \
   1.474 +	*t_cp++ = t_l >> 8; \
   1.475 +	*t_cp   = t_l; \
   1.476 +	(cp) += INT32SZ; \
   1.477 +}
   1.478 +
   1.479 +#ifdef __cplusplus
   1.480 +}
   1.481 +#endif
   1.482 +#endif /* !_ARPA_NAMESER_H_ */