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