arpa_nameser.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1983, 1989, 1993
00003  *    The Regents of the University of California.  All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. All advertising materials mentioning features or use of this software
00014  *    must display the following acknowledgement:
00015  *      This product includes software developed by the University of
00016  *      California, Berkeley and its contributors.
00017  * 4. Neither the name of the University nor the names of its contributors
00018  *    may be used to endorse or promote products derived from this software
00019  *    without specific prior written permission.
00020  * 
00021  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00022  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00024  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00025  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00026  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00027  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00028  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00030  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00031  * SUCH DAMAGE.
00032  */
00033 
00034 /*
00035  * Copyright (c) 1996-1999 by Internet Software Consortium.
00036  *
00037  * Permission to use, copy, modify, and distribute this software for any
00038  * purpose with or without fee is hereby granted, provided that the above
00039  * copyright notice and this permission notice appear in all copies.
00040  *
00041  * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
00042  * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
00043  * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
00044  * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
00045  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
00046  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
00047  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00048  * SOFTWARE.
00049  */
00050 
00051 /*
00052  *      $Id: nameser.h,v 1.2.2.4 2003/06/27 03:51:37 marka Exp $
00053  */
00054 
00055 #ifndef REPLACE_ARPA_NAMESER_H_
00056 #define REPLACE_ARPA_NAMESER_H_
00057 
00058 #ifndef __P
00059 #  define __P(x) x
00060 #endif
00061 
00062 #if defined( HAVE_ARPA_NAMESER_H ) && defined( HAVE_NS_TYPE )
00063 #define dn_expand               __dn_expand
00064 int             dn_expand __P((const u_char *, const u_char *, const u_char *,
00065                                char *, int));
00066 #endif
00067 #define dn_skipname             __dn_skipname
00068 int             dn_skipname __P((const u_char *, const u_char *));
00069 
00070 #include <sys/param.h>
00071 #ifdef HAVE_SYS_TYPES_H
00072 #include <sys/types.h>    /* types (u_char .. etc..) */
00073 #endif
00074 
00075 #ifdef HAVE_INTTYPES_H
00076 #include <inttypes.h>
00077 #endif
00078 
00079 #ifndef HAVE_U_INT8_T
00080 # ifdef HAVE_UINT8_T
00081     typedef uint8_t u_int8_t;
00082 # else
00083     typedef unsigned char u_int8_t;
00084 # endif
00085 #endif
00086 
00087 #ifndef HAVE_U_INT16_T
00088 # ifdef HAVE_UINT16_T
00089     typedef uint16_t u_int16_t;
00090 # else
00091     typedef unsigned short u_int16_t;
00092 # endif
00093 #endif
00094 
00095 #ifndef HAVE_U_INT32_T
00096 # ifdef HAVE_UINT32_T
00097     typedef uint32_t u_int32_t;
00098 # else
00099     typedef unsigned int u_int32_t;
00100 # endif
00101 #endif
00102 
00103 
00104 #if 0
00105 #if (!defined(BSD)) || (BSD < 199306)
00106 # include <sys/bitypes.h>
00107 #else
00108 # include <sys/types.h>
00109 #endif
00110 #include <sys/cdefs.h>
00111 #endif
00112 
00113 /*
00114  * Revision information.  This is the release date in YYYYMMDD format.
00115  * It can change every day so the right thing to do with it is use it
00116  * in preprocessor commands such as "#if (__NAMESER > 19931104)".  Do not
00117  * compare for equality; rather, use it to determine whether your libbind.a
00118  * contains a new enough lib/nameser/ to support the feature you need.
00119  */
00120 
00121 #define __NAMESER       19991006        /* New interface version stamp. */
00122 
00123 /*
00124  * Define constants based on RFC 883, RFC 1034, RFC 1035
00125  */
00126 #define NS_PACKETSZ     512     /* default UDP packet size */
00127 #define NS_MAXDNAME     1025    /* maximum domain name */
00128 #define NS_MAXMSG       65535   /* maximum message size */
00129 #define NS_MAXCDNAME    255     /* maximum compressed domain name */
00130 #define NS_MAXLABEL     63      /* maximum length of domain label */
00131 #define NS_HFIXEDSZ     12      /* #/bytes of fixed data in header */
00132 #define NS_QFIXEDSZ     4       /* #/bytes of fixed data in query */
00133 #define NS_RRFIXEDSZ    10      /* #/bytes of fixed data in r record */
00134 #define NS_INT32SZ      4       /* #/bytes of data in a u_int32_t */
00135 #define NS_INT16SZ      2       /* #/bytes of data in a u_int16_t */
00136 #define NS_INT8SZ       1       /* #/bytes of data in a u_int8_t */
00137 #define NS_INADDRSZ     4       /* IPv4 T_A */
00138 #define NS_IN6ADDRSZ    16      /* IPv6 T_AAAA */
00139 #define NS_CMPRSFLGS    0xc0    /* Flag bits indicating name compression. */
00140 #define NS_DEFAULTPORT  53      /* For both TCP and UDP. */
00141 
00142 /*
00143  * These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord()
00144  * in synch with it.
00145  */
00146 typedef enum __ns_sect {
00147         ns_s_qd = 0,            /* Query: Question. */
00148         ns_s_zn = 0,            /* Update: Zone. */
00149         ns_s_an = 1,            /* Query: Answer. */
00150         ns_s_pr = 1,            /* Update: Prerequisites. */
00151         ns_s_ns = 2,            /* Query: Name servers. */
00152         ns_s_ud = 2,            /* Update: Update. */
00153         ns_s_ar = 3,            /* Query|Update: Additional records. */
00154         ns_s_max = 4
00155 } ns_sect;
00156 
00157 /*
00158  * This is a message handle.  It is caller allocated and has no dynamic data.
00159  * This structure is intended to be opaque to all but ns_parse.c, thus the
00160  * leading _'s on the member names.  Use the accessor functions, not the _'s.
00161  */
00162 typedef struct __ns_msg {
00163         const u_char    *_msg, *_eom;
00164         u_int16_t       _id, _flags, _counts[ns_s_max];
00165         const u_char    *_sections[ns_s_max];
00166         ns_sect         _sect;
00167         int             _rrnum;
00168         const u_char    *_msg_ptr;
00169 } ns_msg;
00170 
00171 /* Private data structure - do not use from outside library. */
00172 struct _ns_flagdata {  int mask, shift;  };
00173 extern struct _ns_flagdata _ns_flagdata[];
00174 
00175 /* Accessor macros - this is part of the public interface. */
00176 
00177 #define ns_msg_id(handle) ((handle)._id + 0)
00178 #define ns_msg_base(handle) ((handle)._msg + 0)
00179 #define ns_msg_end(handle) ((handle)._eom + 0)
00180 #define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
00181 #define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
00182 
00183 /*
00184  * This is a parsed record.  It is caller allocated and has no dynamic data.
00185  */
00186 typedef struct __ns_rr {
00187         char            name[NS_MAXDNAME];
00188         u_int16_t       type;
00189         u_int16_t       rr_class;
00190         u_int32_t       ttl;
00191         u_int16_t       rdlength;
00192         const u_char *  rdata;
00193 } ns_rr;
00194 
00195 /* Accessor macros - this is part of the public interface. */
00196 #define ns_rr_name(rr)  (((rr).name[0] != '\0') ? (rr).name : ".")
00197 #define ns_rr_type(rr)  ((ns_type)((rr).type + 0))
00198 #define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0))
00199 #define ns_rr_ttl(rr)   ((rr).ttl + 0)
00200 #define ns_rr_rdlen(rr) ((rr).rdlength + 0)
00201 #define ns_rr_rdata(rr) ((rr).rdata + 0)
00202 
00203 /*
00204  * These don't have to be in the same order as in the packet flags word,
00205  * and they can even overlap in some cases, but they will need to be kept
00206  * in synch with ns_parse.c:ns_flagdata[].
00207  */
00208 typedef enum __ns_flag {
00209         ns_f_qr,                /* Question/Response. */
00210         ns_f_opcode,            /* Operation code. */
00211         ns_f_aa,                /* Authoritative Answer. */
00212         ns_f_tc,                /* Truncation occurred. */
00213         ns_f_rd,                /* Recursion Desired. */
00214         ns_f_ra,                /* Recursion Available. */
00215         ns_f_z,                 /* MBZ. */
00216         ns_f_ad,                /* Authentic Data (DNSSEC). */
00217         ns_f_cd,                /* Checking Disabled (DNSSEC). */
00218         ns_f_rcode,             /* Response code. */
00219         ns_f_max
00220 } ns_flag;
00221 
00222 /*
00223  * Currently defined opcodes.
00224  */
00225 typedef enum __ns_opcode {
00226         ns_o_query = 0,         /* Standard query. */
00227         ns_o_iquery = 1,        /* Inverse query (deprecated/unsupported). */
00228         ns_o_status = 2,        /* Name server status query (unsupported). */
00229                                 /* Opcode 3 is undefined/reserved. */
00230         ns_o_notify = 4,        /* Zone change notification. */
00231         ns_o_update = 5,        /* Zone update message. */
00232         ns_o_max = 6
00233 } ns_opcode;
00234 
00235 /*
00236  * Currently defined response codes.
00237  */
00238 typedef enum __ns_rcode {
00239         ns_r_noerror = 0,       /* No error occurred. */
00240         ns_r_formerr = 1,       /* Format error. */
00241         ns_r_servfail = 2,      /* Server failure. */
00242         ns_r_nxdomain = 3,      /* Name error. */
00243         ns_r_notimpl = 4,       /* Unimplemented. */
00244         ns_r_refused = 5,       /* Operation refused. */
00245         /* these are for BIND_UPDATE */
00246         ns_r_yxdomain = 6,      /* Name exists */
00247         ns_r_yxrrset = 7,       /* RRset exists */
00248         ns_r_nxrrset = 8,       /* RRset does not exist */
00249         ns_r_notauth = 9,       /* Not authoritative for zone */
00250         ns_r_notzone = 10,      /* Zone of record different from zone section */
00251         ns_r_max = 11,
00252         /* The following are EDNS extended rcodes */
00253         ns_r_badvers = 16,
00254         /* The following are TSIG errors */
00255         ns_r_badsig = 16,
00256         ns_r_badkey = 17,
00257         ns_r_badtime = 18
00258 } ns_rcode;
00259 
00260 /* BIND_UPDATE */
00261 typedef enum __ns_update_operation {
00262         ns_uop_delete = 0,
00263         ns_uop_add = 1,
00264         ns_uop_max = 2
00265 } ns_update_operation;
00266 
00267 /*
00268  * This structure is used for TSIG authenticated messages
00269  */
00270 struct ns_tsig_key {
00271         char name[NS_MAXDNAME], alg[NS_MAXDNAME];
00272         unsigned char *data;
00273         int len;
00274 };
00275 typedef struct ns_tsig_key ns_tsig_key;
00276 
00277 /*
00278  * This structure is used for TSIG authenticated TCP messages
00279  */
00280 struct ns_tcp_tsig_state {
00281         int counter;
00282         struct dst_key *key;
00283         void *ctx;
00284         unsigned char sig[NS_PACKETSZ];
00285         int siglen;
00286 };
00287 typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
00288 
00289 #define NS_TSIG_FUDGE 300
00290 #define NS_TSIG_TCP_COUNT 100
00291 #define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
00292 
00293 #define NS_TSIG_ERROR_NO_TSIG -10
00294 #define NS_TSIG_ERROR_NO_SPACE -11
00295 #define NS_TSIG_ERROR_FORMERR -12
00296 
00297 /*
00298  * Currently defined type values for resources and queries.
00299  */
00300 typedef enum __ns_type {
00301         ns_t_invalid = 0,       /* Cookie. */
00302         ns_t_a = 1,             /* Host address. */
00303         ns_t_ns = 2,            /* Authoritative server. */
00304         ns_t_md = 3,            /* Mail destination. */
00305         ns_t_mf = 4,            /* Mail forwarder. */
00306         ns_t_cname = 5,         /* Canonical name. */
00307         ns_t_soa = 6,           /* Start of authority zone. */
00308         ns_t_mb = 7,            /* Mailbox domain name. */
00309         ns_t_mg = 8,            /* Mail group member. */
00310         ns_t_mr = 9,            /* Mail rename name. */
00311         ns_t_null = 10,         /* Null resource record. */
00312         ns_t_wks = 11,          /* Well known service. */
00313         ns_t_ptr = 12,          /* Domain name pointer. */
00314         ns_t_hinfo = 13,        /* Host information. */
00315         ns_t_minfo = 14,        /* Mailbox information. */
00316         ns_t_mx = 15,           /* Mail routing information. */
00317         ns_t_txt = 16,          /* Text strings. */
00318         ns_t_rp = 17,           /* Responsible person. */
00319         ns_t_afsdb = 18,        /* AFS cell database. */
00320         ns_t_x25 = 19,          /* X_25 calling address. */
00321         ns_t_isdn = 20,         /* ISDN calling address. */
00322         ns_t_rt = 21,           /* Router. */
00323         ns_t_nsap = 22,         /* NSAP address. */
00324         ns_t_nsap_ptr = 23,     /* Reverse NSAP lookup (deprecated). */
00325         ns_t_sig = 24,          /* Security signature. */
00326         ns_t_key = 25,          /* Security key. */
00327         ns_t_px = 26,           /* X.400 mail mapping. */
00328         ns_t_gpos = 27,         /* Geographical position (withdrawn). */
00329         ns_t_aaaa = 28,         /* Ip6 Address. */
00330         ns_t_loc = 29,          /* Location Information. */
00331         ns_t_nxt = 30,          /* Next domain (security). */
00332         ns_t_eid = 31,          /* Endpoint identifier. */
00333         ns_t_nimloc = 32,       /* Nimrod Locator. */
00334         ns_t_srv = 33,          /* Server Selection. */
00335         ns_t_atma = 34,         /* ATM Address */
00336         ns_t_naptr = 35,        /* Naming Authority PoinTeR */
00337         ns_t_kx = 36,           /* Key Exchange */
00338         ns_t_cert = 37,         /* Certification record */
00339         ns_t_a6 = 38,           /* IPv6 address (deprecates AAAA) */
00340         ns_t_dname = 39,        /* Non-terminal DNAME (for IPv6) */
00341         ns_t_sink = 40,         /* Kitchen sink (experimentatl) */
00342         ns_t_opt = 41,          /* EDNS0 option (meta-RR) */
00343         ns_t_apl = 42,          /* Address prefix list (RFC 3123) */
00344         ns_t_tkey = 249,        /* Transaction key */
00345         ns_t_tsig = 250,        /* Transaction signature. */
00346         ns_t_ixfr = 251,        /* Incremental zone transfer. */
00347         ns_t_axfr = 252,        /* Transfer zone of authority. */
00348         ns_t_mailb = 253,       /* Transfer mailbox records. */
00349         ns_t_maila = 254,       /* Transfer mail agent records. */
00350         ns_t_any = 255,         /* Wildcard match. */
00351         ns_t_zxfr = 256,        /* BIND-specific, nonstandard. */
00352         ns_t_max = 65536
00353 } ns_type;
00354 
00355 /* Exclusively a QTYPE? (not also an RTYPE) */
00356 #define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \
00357                       (t) == ns_t_mailb || (t) == ns_t_maila)
00358 /* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */
00359 #define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt)
00360 /* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */
00361 #define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t))
00362 #define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr)
00363 #define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \
00364                        (t) == ns_t_zxfr)
00365 
00366 /*
00367  * Values for class field
00368  */
00369 typedef enum __ns_class {
00370         ns_c_invalid = 0,       /* Cookie. */
00371         ns_c_in = 1,            /* Internet. */
00372         ns_c_2 = 2,             /* unallocated/unsupported. */
00373         ns_c_chaos = 3,         /* MIT Chaos-net. */
00374         ns_c_hs = 4,            /* MIT Hesiod. */
00375         /* Query class values which do not appear in resource records */
00376         ns_c_none = 254,        /* for prereq. sections in update requests */
00377         ns_c_any = 255,         /* Wildcard match. */
00378         ns_c_max = 65536
00379 } ns_class;
00380 
00381 /* DNSSEC constants. */
00382 
00383 typedef enum __ns_key_types {
00384         ns_kt_rsa = 1,          /* key type RSA/MD5 */
00385         ns_kt_dh  = 2,          /* Diffie Hellman */
00386         ns_kt_dsa = 3,          /* Digital Signature Standard (MANDATORY) */
00387         ns_kt_private = 254     /* Private key type starts with OID */
00388 } ns_key_types;
00389 
00390 typedef enum __ns_cert_types {
00391         cert_t_pkix = 1,        /* PKIX (X.509v3) */
00392         cert_t_spki = 2,        /* SPKI */
00393         cert_t_pgp  = 3,        /* PGP */
00394         cert_t_url  = 253,      /* URL private type */
00395         cert_t_oid  = 254       /* OID private type */
00396 } ns_cert_types;
00397 
00398 /* Flags field of the KEY RR rdata. */
00399 #define NS_KEY_TYPEMASK         0xC000  /* Mask for "type" bits */
00400 #define NS_KEY_TYPE_AUTH_CONF   0x0000  /* Key usable for both */
00401 #define NS_KEY_TYPE_CONF_ONLY   0x8000  /* Key usable for confidentiality */
00402 #define NS_KEY_TYPE_AUTH_ONLY   0x4000  /* Key usable for authentication */
00403 #define NS_KEY_TYPE_NO_KEY      0xC000  /* No key usable for either; no key */
00404 /* The type bits can also be interpreted independently, as single bits: */
00405 #define NS_KEY_NO_AUTH          0x8000  /* Key unusable for authentication */
00406 #define NS_KEY_NO_CONF          0x4000  /* Key unusable for confidentiality */
00407 #define NS_KEY_RESERVED2        0x2000  /* Security is *mandatory* if bit=0 */
00408 #define NS_KEY_EXTENDED_FLAGS   0x1000  /* reserved - must be zero */
00409 #define NS_KEY_RESERVED4        0x0800  /* reserved - must be zero */
00410 #define NS_KEY_RESERVED5        0x0400  /* reserved - must be zero */
00411 #define NS_KEY_NAME_TYPE        0x0300  /* these bits determine the type */
00412 #define NS_KEY_NAME_USER        0x0000  /* key is assoc. with user */
00413 #define NS_KEY_NAME_ENTITY      0x0200  /* key is assoc. with entity eg host */
00414 #define NS_KEY_NAME_ZONE        0x0100  /* key is zone key */
00415 #define NS_KEY_NAME_RESERVED    0x0300  /* reserved meaning */
00416 #define NS_KEY_RESERVED8        0x0080  /* reserved - must be zero */
00417 #define NS_KEY_RESERVED9        0x0040  /* reserved - must be zero */
00418 #define NS_KEY_RESERVED10       0x0020  /* reserved - must be zero */
00419 #define NS_KEY_RESERVED11       0x0010  /* reserved - must be zero */
00420 #define NS_KEY_SIGNATORYMASK    0x000F  /* key can sign RR's of same name */
00421 #define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \
00422                                   NS_KEY_RESERVED4 | \
00423                                   NS_KEY_RESERVED5 | \
00424                                   NS_KEY_RESERVED8 | \
00425                                   NS_KEY_RESERVED9 | \
00426                                   NS_KEY_RESERVED10 | \
00427                                   NS_KEY_RESERVED11 )
00428 #define NS_KEY_RESERVED_BITMASK2 0xFFFF /* no bits defined here */
00429 
00430 /* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */
00431 #define NS_ALG_MD5RSA           1       /* MD5 with RSA */
00432 #define NS_ALG_DH               2       /* Diffie Hellman KEY */
00433 #define NS_ALG_DSA              3       /* DSA KEY */
00434 #define NS_ALG_DSS              NS_ALG_DSA
00435 #define NS_ALG_EXPIRE_ONLY      253     /* No alg, no security */
00436 #define NS_ALG_PRIVATE_OID      254     /* Key begins with OID giving alg */
00437 
00438 /* Protocol values  */
00439 /* value 0 is reserved */
00440 #define NS_KEY_PROT_TLS         1
00441 #define NS_KEY_PROT_EMAIL       2
00442 #define NS_KEY_PROT_DNSSEC      3
00443 #define NS_KEY_PROT_IPSEC       4
00444 #define NS_KEY_PROT_ANY         255
00445 
00446 /* Signatures */
00447 #define NS_MD5RSA_MIN_BITS       512    /* Size of a mod or exp in bits */
00448 #define NS_MD5RSA_MAX_BITS      4096
00449         /* Total of binary mod and exp */
00450 #define NS_MD5RSA_MAX_BYTES     ((NS_MD5RSA_MAX_BITS+7/8)*2+3)
00451         /* Max length of text sig block */
00452 #define NS_MD5RSA_MAX_BASE64    (((NS_MD5RSA_MAX_BYTES+2)/3)*4)
00453 #define NS_MD5RSA_MIN_SIZE      ((NS_MD5RSA_MIN_BITS+7)/8)
00454 #define NS_MD5RSA_MAX_SIZE      ((NS_MD5RSA_MAX_BITS+7)/8)
00455 
00456 #define NS_DSA_SIG_SIZE         41
00457 #define NS_DSA_MIN_SIZE         213
00458 #define NS_DSA_MAX_BYTES        405
00459 
00460 /* Offsets into SIG record rdata to find various values */
00461 #define NS_SIG_TYPE     0       /* Type flags */
00462 #define NS_SIG_ALG      2       /* Algorithm */
00463 #define NS_SIG_LABELS   3       /* How many labels in name */
00464 #define NS_SIG_OTTL     4       /* Original TTL */
00465 #define NS_SIG_EXPIR    8       /* Expiration time */
00466 #define NS_SIG_SIGNED   12      /* Signature time */
00467 #define NS_SIG_FOOT     16      /* Key footprint */
00468 #define NS_SIG_SIGNER   18      /* Domain name of who signed it */
00469 
00470 /* How RR types are represented as bit-flags in NXT records */
00471 #define NS_NXT_BITS 8
00472 #define NS_NXT_BIT_SET(  n,p) (p[(n)/NS_NXT_BITS] |=  (0x80>>((n)%NS_NXT_BITS)))
00473 #define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS)))
00474 #define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] &   (0x80>>((n)%NS_NXT_BITS)))
00475 #define NS_NXT_MAX 127
00476 
00477 /*
00478  * EDNS0 extended flags, host order.
00479  */
00480 #define NS_OPT_DNSSEC_OK        0x8000U
00481 
00482 /*
00483  * Inline versions of get/put short/long.  Pointer is advanced.
00484  */
00485 #define NS_GET16(s, cp) do { \
00486         register const u_char *t_cp = (const u_char *)(cp); \
00487         (s) = ((u_int16_t)t_cp[0] << 8) \
00488             | ((u_int16_t)t_cp[1]) \
00489             ; \
00490         (cp) += NS_INT16SZ; \
00491 } while (0)
00492 
00493 #define NS_GET32(l, cp) do { \
00494         register const u_char *t_cp = (const u_char *)(cp); \
00495         (l) = ((u_int32_t)t_cp[0] << 24) \
00496             | ((u_int32_t)t_cp[1] << 16) \
00497             | ((u_int32_t)t_cp[2] << 8) \
00498             | ((u_int32_t)t_cp[3]) \
00499             ; \
00500         (cp) += NS_INT32SZ; \
00501 } while (0)
00502 
00503 #define NS_PUT16(s, cp) do { \
00504         register u_int16_t t_s = (u_int16_t)(s); \
00505         register u_char *t_cp = (u_char *)(cp); \
00506         *t_cp++ = t_s >> 8; \
00507         *t_cp   = t_s; \
00508         (cp) += NS_INT16SZ; \
00509 } while (0)
00510 
00511 #define NS_PUT32(l, cp) do { \
00512         register u_int32_t t_l = (u_int32_t)(l); \
00513         register u_char *t_cp = (u_char *)(cp); \
00514         *t_cp++ = t_l >> 24; \
00515         *t_cp++ = t_l >> 16; \
00516         *t_cp++ = t_l >> 8; \
00517         *t_cp   = t_l; \
00518         (cp) += NS_INT32SZ; \
00519 } while (0)
00520 
00521 /*
00522  * ANSI C identifier hiding for bind's lib/nameser.
00523  */
00524 #define ns_msg_getflag          __ns_msg_getflag
00525 #define ns_get16                __ns_get16
00526 #define ns_get32                __ns_get32
00527 #define ns_put16                __ns_put16
00528 #define ns_put32                __ns_put32
00529 #define ns_initparse            __ns_initparse
00530 #define ns_skiprr               __ns_skiprr
00531 #define ns_parserr              __ns_parserr
00532 #define ns_sprintrr             __ns_sprintrr
00533 #define ns_sprintrrf            __ns_sprintrrf
00534 #define ns_format_ttl           __ns_format_ttl
00535 #define ns_parse_ttl            __ns_parse_ttl
00536 #define ns_datetosecs           __ns_datetosecs
00537 #define ns_name_ntol            __ns_name_ntol
00538 #define ns_name_ntop            __ns_name_ntop
00539 #define ns_name_pton            __ns_name_pton
00540 #define ns_name_unpack          __ns_name_unpack
00541 #define ns_name_pack            __ns_name_pack
00542 #define ns_name_compress        __ns_name_compress
00543 #define ns_name_uncompress      __ns_name_uncompress
00544 #define ns_name_skip            __ns_name_skip
00545 #define ns_name_rollback        __ns_name_rollback
00546 #define ns_sign                 __ns_sign
00547 #define ns_sign2                __ns_sign2
00548 #define ns_sign_tcp             __ns_sign_tcp
00549 #define ns_sign_tcp2            __ns_sign_tcp2
00550 #define ns_sign_tcp_init        __ns_sign_tcp_init
00551 #define ns_find_tsig            __ns_find_tsig
00552 #define ns_verify               __ns_verify
00553 #define ns_verify_tcp           __ns_verify_tcp
00554 #define ns_verify_tcp_init      __ns_verify_tcp_init
00555 #define ns_samedomain           __ns_samedomain
00556 #define ns_subdomain            __ns_subdomain
00557 #define ns_makecanon            __ns_makecanon
00558 #define ns_samename             __ns_samename
00559 
00560 
00561 int             ns_msg_getflag __P((ns_msg, int));
00562 u_int           ns_get16 __P((const u_char *));
00563 u_long          ns_get32 __P((const u_char *));
00564 void            ns_put16 __P((u_int, u_char *));
00565 void            ns_put32 __P((u_long, u_char *));
00566 int             ns_initparse __P((const u_char *, int, ns_msg *));
00567 int             ns_skiprr __P((const u_char *, const u_char *, ns_sect, int));
00568 int             ns_parserr __P((ns_msg *, ns_sect, int, ns_rr *));
00569 int             ns_sprintrr __P((const ns_msg *, const ns_rr *,
00570                                  const char *, const char *, char *, size_t));
00571 int             ns_sprintrrf __P((const u_char *, size_t, const char *,
00572                                   ns_class, ns_type, u_long, const u_char *,
00573                                   size_t, const char *, const char *,
00574                                   char *, size_t));
00575 int             ns_format_ttl __P((u_long, char *, size_t));
00576 int             ns_parse_ttl __P((const char *, u_long *));
00577 u_int32_t       ns_datetosecs __P((const char *cp, int *errp));
00578 int             ns_name_ntol __P((const u_char *, u_char *, size_t));
00579 int             ns_name_ntop __P((const u_char *, char *, size_t));
00580 int             ns_name_pton __P((const char *, u_char *, size_t));
00581 int             ns_name_unpack __P((const u_char *, const u_char *,
00582                                     const u_char *, u_char *, size_t));
00583 int             ns_name_pack __P((const u_char *, u_char *, int,
00584                                   const u_char **, const u_char **));
00585 int             ns_name_uncompress __P((const u_char *, const u_char *,
00586                                         const u_char *, char *, size_t));
00587 int             ns_name_compress __P((const char *, u_char *, size_t,
00588                                       const u_char **, const u_char **));
00589 int             ns_name_skip __P((const u_char **, const u_char *));
00590 void            ns_name_rollback __P((const u_char *, const u_char **,
00591                                       const u_char **));
00592 int             ns_sign __P((u_char *, int *, int, int, void *,
00593                              const u_char *, int, u_char *, int *, time_t));
00594 int             ns_sign2 __P((u_char *, int *, int, int, void *,
00595                               const u_char *, int, u_char *, int *, time_t,
00596                               u_char **, u_char **));
00597 int             ns_sign_tcp __P((u_char *, int *, int, int,
00598                                  ns_tcp_tsig_state *, int));
00599 int             ns_sign_tcp2 __P((u_char *, int *, int, int,
00600                                   ns_tcp_tsig_state *, int,
00601                                   u_char **, u_char **));
00602 int             ns_sign_tcp_init __P((void *, const u_char *, int,
00603                                         ns_tcp_tsig_state *));
00604 u_char          *ns_find_tsig __P((u_char *, u_char *));
00605 int             ns_verify __P((u_char *, int *, void *,
00606                                const u_char *, int, u_char *, int *,
00607                                time_t *, int));
00608 int             ns_verify_tcp __P((u_char *, int *, ns_tcp_tsig_state *, int));
00609 int             ns_verify_tcp_init __P((void *, const u_char *, int,
00610                                         ns_tcp_tsig_state *));
00611 int             ns_samedomain __P((const char *, const char *));
00612 int             ns_subdomain __P((const char *, const char *));
00613 int             ns_makecanon __P((const char *, char *, size_t));
00614 int             ns_samename __P((const char *, const char *));
00615 
00616 
00617 #endif /* !REPLACE_ARPA_NAMESER_H_ */

Generated on Tue Nov 4 13:27:39 2008 for libspf2 by  doxygen 1.5.4