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