Bring final version of libbind:

From
http://www.isc.org/downloads/libbind/

The libbind functions have been separated from the BIND suite as of BIND
9.6.0. Originally from older versions of BIND, they have been continually
maintained and improved but not installed by default with BIND 9. This
standard resolver library contains the same historical functions and
headers included with many Unix operating systems. In fact, most
implementations are based on the same original code.

At present, NetBSD maintains libbind code, now known as "netresolv".
This commit is contained in:
Pedro F. Giffuni 2014-08-05 23:16:31 +00:00
parent 9aeb4147cc
commit 046c3635cd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/resolver/dist/; revision=269610
48 changed files with 1909 additions and 247 deletions

View File

@ -55,7 +55,7 @@
/*%
* @(#)inet.h 8.1 (Berkeley) 6/2/93
* $Id: inet.h,v 1.2.18.1 2005/04/27 05:00:50 sra Exp $
* $Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp $
*/
#ifndef _INET_H_

View File

@ -1,7 +1,24 @@
/*
* Portions Copyright (C) 2004, 2005, 2008, 2009 Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (C) 1996-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Copyright (c) 1983, 1989, 1993
* The Regents of the University of California. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -17,7 +34,7 @@
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -32,24 +49,7 @@
*/
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* $Id: nameser.h,v 1.7.18.2 2008/04/03 23:15:15 marka Exp $
* $Id: nameser.h,v 1.16 2009/03/03 01:52:48 each Exp $
*/
#ifndef _ARPA_NAMESER_H_
@ -75,15 +75,18 @@
* contains a new enough lib/nameser/ to support the feature you need.
*/
#define __NAMESER 19991006 /*%< New interface version stamp. */
#define __NAMESER 20090302 /*%< New interface version stamp. */
/*
* Define constants based on RFC0883, RFC1034, RFC 1035
*/
#define NS_PACKETSZ 512 /*%< default UDP packet size */
#define NS_MAXDNAME 1025 /*%< maximum domain name */
#define NS_MAXDNAME 1025 /*%< maximum domain name (presentation format)*/
#define NS_MAXMSG 65535 /*%< maximum message size */
#define NS_MAXCDNAME 255 /*%< maximum compressed domain name */
#define NS_MAXLABEL 63 /*%< maximum length of domain label */
#define NS_MAXLABELS 128 /*%< theoretical max #/labels per domain name */
#define NS_MAXNNAME 256 /*%< maximum uncompressed (binary) domain name*/
#define NS_MAXPADDR (sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
#define NS_HFIXEDSZ 12 /*%< #/bytes of fixed data in header */
#define NS_QFIXEDSZ 4 /*%< #/bytes of fixed data in query */
#define NS_RRFIXEDSZ 10 /*%< #/bytes of fixed data in r record */
@ -109,6 +112,18 @@ typedef enum __ns_sect {
ns_s_max = 4
} ns_sect;
/*%
* Network name (compressed or not) type. Equivilent to a pointer when used
* in a function prototype. Can be const'd.
*/
typedef u_char ns_nname[NS_MAXNNAME];
typedef const u_char *ns_nname_ct;
typedef u_char *ns_nname_t;
struct ns_namemap { ns_nname_ct base; int len; };
typedef struct ns_namemap *ns_namemap_t;
typedef const struct ns_namemap *ns_namemap_ct;
/*%
* This is a message handle. It is caller allocated and has no dynamic data.
* This structure is intended to be opaque to all but ns_parse.c, thus the
@ -123,6 +138,17 @@ typedef struct __ns_msg {
const u_char *_msg_ptr;
} ns_msg;
/*
* This is a newmsg handle, used when constructing new messages with
* ns_newmsg_init, et al.
*/
struct ns_newmsg {
ns_msg msg;
const u_char *dnptrs[25];
const u_char **lastdnptr;
};
typedef struct ns_newmsg ns_newmsg;
/* Private data structure - do not use from outside library. */
struct _ns_flagdata { int mask, shift; };
extern struct _ns_flagdata _ns_flagdata[];
@ -147,8 +173,23 @@ typedef struct __ns_rr {
const u_char * rdata;
} ns_rr;
/*
* Same thing, but using uncompressed network binary names, and real C types.
*/
typedef struct __ns_rr2 {
ns_nname nname;
size_t nnamel;
int type;
int rr_class;
u_int ttl;
int rdlength;
const u_char * rdata;
} ns_rr2;
/* Accessor macros - this is part of the public interface. */
#define ns_rr_name(rr) (((rr).name[0] != '\0') ? (rr).name : ".")
#define ns_rr_nname(rr) ((const ns_nname_t)(rr).nname)
#define ns_rr_nnamel(rr) ((rr).nnamel + 0)
#define ns_rr_type(rr) ((ns_type)((rr).type + 0))
#define ns_rr_class(rr) ((ns_class)((rr).rr_class + 0))
#define ns_rr_ttl(rr) ((rr).ttl + 0)
@ -223,9 +264,9 @@ typedef enum __ns_update_operation {
* This structure is used for TSIG authenticated messages
*/
struct ns_tsig_key {
char name[NS_MAXDNAME], alg[NS_MAXDNAME];
unsigned char *data;
int len;
char name[NS_MAXDNAME], alg[NS_MAXDNAME];
unsigned char *data;
int len;
};
typedef struct ns_tsig_key ns_tsig_key;
@ -281,7 +322,7 @@ typedef enum __ns_type {
ns_t_key = 25, /*%< Security key. */
ns_t_px = 26, /*%< X.400 mail mapping. */
ns_t_gpos = 27, /*%< Geographical position (withdrawn). */
ns_t_aaaa = 28, /*%< Ip6 Address. */
ns_t_aaaa = 28, /*%< IPv6 Address. */
ns_t_loc = 29, /*%< Location Information. */
ns_t_nxt = 30, /*%< Next domain (security). */
ns_t_eid = 31, /*%< Endpoint identifier. */
@ -291,11 +332,22 @@ typedef enum __ns_type {
ns_t_naptr = 35, /*%< Naming Authority PoinTeR */
ns_t_kx = 36, /*%< Key Exchange */
ns_t_cert = 37, /*%< Certification record */
ns_t_a6 = 38, /*%< IPv6 address (deprecates AAAA) */
ns_t_dname = 39, /*%< Non-terminal DNAME (for IPv6) */
ns_t_a6 = 38, /*%< IPv6 address (experimental) */
ns_t_dname = 39, /*%< Non-terminal DNAME */
ns_t_sink = 40, /*%< Kitchen sink (experimentatl) */
ns_t_opt = 41, /*%< EDNS0 option (meta-RR) */
ns_t_apl = 42, /*%< Address prefix list (RFC3123) */
ns_t_ds = 43, /*%< Delegation Signer */
ns_t_sshfp = 44, /*%< SSH Fingerprint */
ns_t_ipseckey = 45, /*%< IPSEC Key */
ns_t_rrsig = 46, /*%< RRset Signature */
ns_t_nsec = 47, /*%< Negative security */
ns_t_dnskey = 48, /*%< DNS Key */
ns_t_dhcid = 49, /*%< Dynamic host configuratin identifier */
ns_t_nsec3 = 50, /*%< Negative security type 3 */
ns_t_nsec3param = 51, /*%< Negative security type 3 parameters */
ns_t_hip = 55, /*%< Host Identity Protocol */
ns_t_spf = 99, /*%< Sender Policy Framework */
ns_t_tkey = 249, /*%< Transaction key */
ns_t_tsig = 250, /*%< Transaction signature. */
ns_t_ixfr = 251, /*%< Incremental zone transfer. */
@ -304,6 +356,7 @@ typedef enum __ns_type {
ns_t_maila = 254, /*%< Transfer mail agent records. */
ns_t_any = 255, /*%< Wildcard match. */
ns_t_zxfr = 256, /*%< BIND-specific, nonstandard. */
ns_t_dlv = 32769, /*%< DNSSEC look-aside validatation. */
ns_t_max = 65536
} ns_type;
@ -482,6 +535,7 @@ typedef enum __ns_cert_types {
#define ns_initparse __ns_initparse
#define ns_skiprr __ns_skiprr
#define ns_parserr __ns_parserr
#define ns_parserr2 __ns_parserr2
#define ns_sprintrr __ns_sprintrr
#define ns_sprintrrf __ns_sprintrrf
#define ns_format_ttl __ns_format_ttl
@ -490,12 +544,19 @@ typedef enum __ns_cert_types {
#define ns_name_ntol __ns_name_ntol
#define ns_name_ntop __ns_name_ntop
#define ns_name_pton __ns_name_pton
#define ns_name_pton2 __ns_name_pton2
#define ns_name_unpack __ns_name_unpack
#define ns_name_unpack2 __ns_name_unpack2
#define ns_name_pack __ns_name_pack
#define ns_name_compress __ns_name_compress
#define ns_name_uncompress __ns_name_uncompress
#define ns_name_skip __ns_name_skip
#define ns_name_rollback __ns_name_rollback
#define ns_name_length __ns_name_length
#define ns_name_eq __ns_name_eq
#define ns_name_owned __ns_name_owned
#define ns_name_map __ns_name_map
#define ns_name_labels __ns_name_labels
#define ns_sign __ns_sign
#define ns_sign2 __ns_sign2
#define ns_sign_tcp __ns_sign_tcp
@ -509,6 +570,16 @@ typedef enum __ns_cert_types {
#define ns_subdomain __ns_subdomain
#define ns_makecanon __ns_makecanon
#define ns_samename __ns_samename
#define ns_newmsg_init __ns_newmsg_init
#define ns_newmsg_copy __ns_newmsg_copy
#define ns_newmsg_id __ns_newmsg_id
#define ns_newmsg_flag __ns_newmsg_flag
#define ns_newmsg_q __ns_newmsg_q
#define ns_newmsg_rr __ns_newmsg_rr
#define ns_newmsg_done __ns_newmsg_done
#define ns_rdata_unpack __ns_rdata_unpack
#define ns_rdata_equal __ns_rdata_equal
#define ns_rdata_refers __ns_rdata_refers
__BEGIN_DECLS
int ns_msg_getflag __P((ns_msg, int));
@ -519,6 +590,7 @@ void ns_put32 __P((u_long, u_char *));
int ns_initparse __P((const u_char *, int, ns_msg *));
int ns_skiprr __P((const u_char *, const u_char *, ns_sect, int));
int ns_parserr __P((ns_msg *, ns_sect, int, ns_rr *));
int ns_parserr2 __P((ns_msg *, ns_sect, int, ns_rr2 *));
int ns_sprintrr __P((const ns_msg *, const ns_rr *,
const char *, const char *, char *, size_t));
int ns_sprintrrf __P((const u_char *, size_t, const char *,
@ -531,8 +603,12 @@ u_int32_t ns_datetosecs __P((const char *cp, int *errp));
int ns_name_ntol __P((const u_char *, u_char *, size_t));
int ns_name_ntop __P((const u_char *, char *, size_t));
int ns_name_pton __P((const char *, u_char *, size_t));
int ns_name_pton2 __P((const char *, u_char *, size_t, size_t *));
int ns_name_unpack __P((const u_char *, const u_char *,
const u_char *, u_char *, size_t));
int ns_name_unpack2 __P((const u_char *, const u_char *,
const u_char *, u_char *, size_t,
size_t *));
int ns_name_pack __P((const u_char *, u_char *, int,
const u_char **, const u_char **));
int ns_name_uncompress __P((const u_char *, const u_char *,
@ -542,6 +618,11 @@ int ns_name_compress __P((const char *, u_char *, size_t,
int ns_name_skip __P((const u_char **, const u_char *));
void ns_name_rollback __P((const u_char *, const u_char **,
const u_char **));
ssize_t ns_name_length(ns_nname_ct, size_t);
int ns_name_eq(ns_nname_ct, size_t, ns_nname_ct, size_t);
int ns_name_owned(ns_namemap_ct, int, ns_namemap_ct, int);
int ns_name_map(ns_nname_ct, size_t, ns_namemap_t, int);
int ns_name_labels(ns_nname_ct, size_t);
int ns_sign __P((u_char *, int *, int, int, void *,
const u_char *, int, u_char *, int *, time_t));
int ns_sign2 __P((u_char *, int *, int, int, void *,
@ -565,6 +646,25 @@ int ns_samedomain __P((const char *, const char *));
int ns_subdomain __P((const char *, const char *));
int ns_makecanon __P((const char *, char *, size_t));
int ns_samename __P((const char *, const char *));
int ns_newmsg_init(u_char *buffer, size_t bufsiz, ns_newmsg *);
int ns_newmsg_copy(ns_newmsg *, ns_msg *);
void ns_newmsg_id(ns_newmsg *handle, u_int16_t id);
void ns_newmsg_flag(ns_newmsg *handle, ns_flag flag, u_int value);
int ns_newmsg_q(ns_newmsg *handle, ns_nname_ct qname,
ns_type qtype, ns_class qclass);
int ns_newmsg_rr(ns_newmsg *handle, ns_sect sect,
ns_nname_ct name, ns_type type,
ns_class rr_class, u_int32_t ttl,
u_int16_t rdlen, const u_char *rdata);
size_t ns_newmsg_done(ns_newmsg *handle);
ssize_t ns_rdata_unpack(const u_char *, const u_char *, ns_type,
const u_char *, size_t, u_char *, size_t);
int ns_rdata_equal(ns_type,
const u_char *, size_t,
const u_char *, size_t);
int ns_rdata_refers(ns_type,
const u_char *, size_t,
const u_char *);
__END_DECLS
#ifdef BIND_4_COMPAT

View File

@ -32,7 +32,7 @@
/*%
* from nameser.h 8.1 (Berkeley) 6/2/93
* $Id: nameser_compat.h,v 1.5.18.3 2006/05/19 02:36:00 marka Exp $
* $Id: nameser_compat.h,v 1.8 2006/05/19 02:33:40 marka Exp $
*/
#ifndef _ARPA_NAMESER_COMPAT_

39
include/hesiod.h Normal file
View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996,1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*! \file
* \brief
* This file is primarily maintained by <tytso@mit.edu> and <ghudson@mit.edu>.
*/
/*
* $Id: hesiod.h,v 1.4 2005/04/27 04:56:14 sra Exp $
*/
#ifndef _HESIOD_H_INCLUDED
#define _HESIOD_H_INCLUDED
int hesiod_init __P((void **));
void hesiod_end __P((void *));
char * hesiod_to_bind __P((void *, const char *, const char *));
char ** hesiod_resolve __P((void *, const char *, const char *));
void hesiod_free_list __P((void *, char **));
struct __res_state * __hesiod_res_get __P((void *));
void __hesiod_res_set __P((void *, struct __res_state *,
void (*)(void *)));
#endif /*_HESIOD_H_INCLUDED*/

26
include/netgroup.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef netgroup_h
#define netgroup_h
#ifndef __GLIBC__
/*
* The standard is crazy. These values "belong" to getnetgrent() and
* shouldn't be altered by the caller.
*/
int getnetgrent __P((/* const */ char **, /* const */ char **,
/* const */ char **));
int getnetgrent_r __P((char **, char **, char **, char *, int));
void endnetgrent __P((void));
#ifdef __osf__
int innetgr __P((char *, char *, char *, char *));
void setnetgrent __P((char *));
#else
void setnetgrent __P((const char *));
int innetgr __P((const char *, const char *, const char *, const char *));
#endif
#endif
#endif
/*! \file */

View File

@ -16,7 +16,7 @@
*/
/*
* $Id: res_update.h,v 1.2.18.1 2005/04/27 05:00:49 sra Exp $
* $Id: res_update.h,v 1.3 2005/04/27 04:56:15 sra Exp $
*/
#ifndef __RES_UPDATE_H

View File

@ -1,7 +1,24 @@
/*
* Portions Copyright (C) 2004, 2005, 2008, 2009 Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (C) 1995-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Copyright (c) 1983, 1987, 1989
* The Regents of the University of California. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -17,7 +34,7 @@
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -31,26 +48,9 @@
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*%
* @(#)resolv.h 8.1 (Berkeley) 6/2/93
* $Id: resolv.h,v 1.19.18.4 2008/04/03 23:15:15 marka Exp $
* $Id: resolv.h,v 1.30 2009/03/03 01:52:48 each Exp $
*/
#ifndef _RESOLV_H_
@ -75,7 +75,7 @@
* is new enough to contain a certain feature.
*/
#define __RES 20030124
#define __RES 20090302
/*%
* This used to be defined in res_query.c, now it's in herror.c.
@ -185,10 +185,11 @@ struct __res_state {
int res_h_errno; /*%< last one set for this context */
int _vcsock; /*%< PRIVATE: for res_send VC i/o */
u_int _flags; /*%< PRIVATE: see below */
u_char _rnd[16]; /*%< PRIVATE: random state */
u_int _pad; /*%< make _u 64 bit aligned */
union {
/* On an 32-bit arch this means 512b total. */
char pad[72 - 4*sizeof (int) - 2*sizeof (void *)];
char pad[56 - 4*sizeof (int) - 2*sizeof (void *)];
struct {
u_int16_t nscount;
u_int16_t nstimes[MAXNS]; /*%< ms. */
@ -338,7 +339,7 @@ __END_DECLS
#if !defined(SHARED_LIBBIND) || defined(LIB)
/*
* If libbind is a shared object (well, DLL anyway)
* these externs break the linker when resolv.h is
* these externs break the linker when resolv.h is
* included by a lib client (like named)
* Make them go away if a client is including this
*
@ -392,7 +393,9 @@ extern const struct res_sym __p_rcode_syms[];
#define res_nisourserver __res_nisourserver
#define res_ownok __res_ownok
#define res_queriesmatch __res_queriesmatch
#define res_rndinit __res_rndinit
#define res_randomid __res_randomid
#define res_nrandomid __res_nrandomid
#define sym_ntop __sym_ntop
#define sym_ntos __sym_ntos
#define sym_ston __sym_ston
@ -451,7 +454,9 @@ int dn_comp __P((const char *, u_char *, int,
u_char **, u_char **));
int dn_expand __P((const u_char *, const u_char *, const u_char *,
char *, int));
void res_rndinit __P((res_state));
u_int res_randomid __P((void));
u_int res_nrandomid __P((res_state));
int res_nameinquery __P((const char *, int, int, const u_char *,
const u_char *));
int res_queriesmatch __P((const u_char *, const u_char *,

View File

@ -0,0 +1,10 @@
#ifndef _FD_SETSIZE_H
#define _FD_SETSIZE_H
/*%
* If you need a bigger FD_SETSIZE, this is NOT the place to set it.
* This file is a fallback for BIND ports which don't specify their own.
*/
#endif /* _FD_SETSIZE_H */
/*! \file */

View File

@ -0,0 +1,123 @@
/*
* Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1997-2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* $Id: assertions.h,v 1.5 2008/11/14 02:36:51 marka Exp $
*/
#ifndef ASSERTIONS_H
#define ASSERTIONS_H 1
typedef enum {
assert_require, assert_ensure, assert_insist, assert_invariant
} assertion_type;
typedef void (*assertion_failure_callback)(const char *, int, assertion_type,
const char *, int);
/* coverity[+kill] */
extern assertion_failure_callback __assertion_failed;
void set_assertion_failure_callback(assertion_failure_callback f);
const char *assertion_type_to_text(assertion_type type);
#if defined(CHECK_ALL) || defined(__COVERITY__)
#define CHECK_REQUIRE 1
#define CHECK_ENSURE 1
#define CHECK_INSIST 1
#define CHECK_INVARIANT 1
#endif
#if defined(CHECK_NONE) && !defined(__COVERITY__)
#define CHECK_REQUIRE 0
#define CHECK_ENSURE 0
#define CHECK_INSIST 0
#define CHECK_INVARIANT 0
#endif
#ifndef CHECK_REQUIRE
#define CHECK_REQUIRE 1
#endif
#ifndef CHECK_ENSURE
#define CHECK_ENSURE 1
#endif
#ifndef CHECK_INSIST
#define CHECK_INSIST 1
#endif
#ifndef CHECK_INVARIANT
#define CHECK_INVARIANT 1
#endif
#if CHECK_REQUIRE != 0
#define REQUIRE(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_require, \
#cond, 0), 0)))
#define REQUIRE_ERR(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_require, \
#cond, 1), 0)))
#else
#define REQUIRE(cond) ((void) (cond))
#define REQUIRE_ERR(cond) ((void) (cond))
#endif /* CHECK_REQUIRE */
#if CHECK_ENSURE != 0
#define ENSURE(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
#cond, 0), 0)))
#define ENSURE_ERR(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
#cond, 1), 0)))
#else
#define ENSURE(cond) ((void) (cond))
#define ENSURE_ERR(cond) ((void) (cond))
#endif /* CHECK_ENSURE */
#if CHECK_INSIST != 0
#define INSIST(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
#cond, 0), 0)))
#define INSIST_ERR(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
#cond, 1), 0)))
#else
#define INSIST(cond) ((void) (cond))
#define INSIST_ERR(cond) ((void) (cond))
#endif /* CHECK_INSIST */
#if CHECK_INVARIANT != 0
#define INVARIANT(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
#cond, 0), 0)))
#define INVARIANT_ERR(cond) \
((void) ((cond) || \
((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
#cond, 1), 0)))
#else
#define INVARIANT(cond) ((void) (cond))
#define INVARIANT_ERR(cond) ((void) (cond))
#endif /* CHECK_INVARIANT */
#endif /* ASSERTIONS_H */
/*! \file */

168
lib/libc/include/isc/dst.h Normal file
View File

@ -0,0 +1,168 @@
#ifndef DST_H
#define DST_H
#ifndef HAS_DST_KEY
typedef struct dst_key {
char *dk_key_name; /*%< name of the key */
int dk_key_size; /*%< this is the size of the key in bits */
int dk_proto; /*%< what protocols this key can be used for */
int dk_alg; /*%< algorithm number from key record */
u_int32_t dk_flags; /*%< and the flags of the public key */
u_int16_t dk_id; /*%< identifier of the key */
} DST_KEY;
#endif /* HAS_DST_KEY */
/*
* do not taint namespace
*/
#define dst_bsafe_init __dst_bsafe_init
#define dst_buffer_to_key __dst_buffer_to_key
#define dst_check_algorithm __dst_check_algorithm
#define dst_compare_keys __dst_compare_keys
#define dst_cylink_init __dst_cylink_init
#define dst_dnskey_to_key __dst_dnskey_to_key
#define dst_eay_dss_init __dst_eay_dss_init
#define dst_free_key __dst_free_key
#define dst_generate_key __dst_generate_key
#define dst_hmac_md5_init __dst_hmac_md5_init
#define dst_init __dst_init
#define dst_key_to_buffer __dst_key_to_buffer
#define dst_key_to_dnskey __dst_key_to_dnskey
#define dst_read_key __dst_read_key
#define dst_rsaref_init __dst_rsaref_init
#define dst_s_build_filename __dst_s_build_filename
#define dst_s_calculate_bits __dst_s_calculate_bits
#define dst_s_conv_bignum_b64_to_u8 __dst_s_conv_bignum_b64_to_u8
#define dst_s_conv_bignum_u8_to_b64 __dst_s_conv_bignum_u8_to_b64
#define dst_s_dns_key_id __dst_s_dns_key_id
#define dst_s_dump __dst_s_dump
#define dst_s_filename_length __dst_s_filename_length
#define dst_s_fopen __dst_s_fopen
#define dst_s_get_int16 __dst_s_get_int16
#define dst_s_get_int32 __dst_s_get_int32
#define dst_s_id_calc __dst_s_id_calc
#define dst_s_put_int16 __dst_s_put_int16
#define dst_s_put_int32 __dst_s_put_int32
#define dst_s_quick_random __dst_s_quick_random
#define dst_s_quick_random_set __dst_s_quick_random_set
#define dst_s_random __dst_s_random
#define dst_s_semi_random __dst_s_semi_random
#define dst_s_verify_str __dst_s_verify_str
#define dst_sig_size __dst_sig_size
#define dst_sign_data __dst_sign_data
#define dst_verify_data __dst_verify_data
#define dst_write_key __dst_write_key
/*
* DST Crypto API defintions
*/
void dst_init(void);
int dst_check_algorithm(const int);
int dst_sign_data(const int, /*!< specifies INIT/UPDATE/FINAL/ALL */
DST_KEY *, /*!< the key to use */
void **, /*!< pointer to state structure */
const u_char *, /*!< data to be signed */
const int, /*!< length of input data */
u_char *, /*!< buffer to write signature to */
const int); /*!< size of output buffer */
int dst_verify_data(const int, /*!< specifies INIT/UPDATE/FINAL/ALL */
DST_KEY *, /*!< the key to use */
void **, /*!< pointer to state structure */
const u_char *, /*!< data to be verified */
const int, /*!< length of input data */
const u_char *, /*!< buffer containing signature */
const int); /*!< length of signature */
DST_KEY *dst_read_key(const char *, /*!< name of key */
const u_int16_t, /*!< key tag identifier */
const int, /*!< key algorithm */
const int); /*!< Private/PublicKey wanted */
int dst_write_key(const DST_KEY *, /*!< key to write out */
const int); /*!< Public/Private */
DST_KEY *dst_dnskey_to_key(const char *, /*!< KEY record name */
const u_char *, /*!< KEY RDATA */
const int); /*!< size of input buffer */
int dst_key_to_dnskey(const DST_KEY *, /*!< key to translate */
u_char *, /*!< output buffer */
const int); /*!< size of out_storage */
DST_KEY *dst_buffer_to_key(const char *, /*!< name of the key */
const int, /*!< algorithm */
const int, /*!< dns flags */
const int, /*!< dns protocol */
const u_char *, /*!< key in dns wire fmt */
const int); /*!< size of key */
int dst_key_to_buffer(DST_KEY *, u_char *, int);
DST_KEY *dst_generate_key(const char *, /*!< name of new key */
const int, /*!< key algorithm to generate */
const int, /*!< size of new key */
const int, /*!< alg dependent parameter */
const int, /*!< key DNS flags */
const int); /*!< key DNS protocol */
DST_KEY *dst_free_key(DST_KEY *);
int dst_compare_keys(const DST_KEY *, const DST_KEY *);
int dst_sig_size(DST_KEY *);
/* support for dns key tags/ids */
u_int16_t dst_s_dns_key_id(const u_char *, const int);
u_int16_t dst_s_id_calc(const u_char *, const int);
/* Used by callers as well as by the library. */
#define RAW_KEY_SIZE 8192 /*%< large enough to store any key */
/* DST_API control flags */
/* These are used used in functions dst_sign_data and dst_verify_data */
#define SIG_MODE_INIT 1 /*%< initialize digest */
#define SIG_MODE_UPDATE 2 /*%< add data to digest */
#define SIG_MODE_FINAL 4 /*%< generate/verify signature */
#define SIG_MODE_ALL (SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL)
/* Flags for dst_read_private_key() */
#define DST_FORCE_READ 0x1000000
#define DST_CAN_SIGN 0x010F
#define DST_NO_AUTHEN 0x8000
#define DST_EXTEND_FLAG 0x1000
#define DST_STANDARD 0
#define DST_PRIVATE 0x2000000
#define DST_PUBLIC 0x4000000
#define DST_RAND_SEMI 1
#define DST_RAND_STD 2
#define DST_RAND_KEY 3
#define DST_RAND_DSS 4
/* DST algorithm codes */
#define KEY_RSA 1
#define KEY_DH 2
#define KEY_DSA 3
#define KEY_PRIVATE 254
#define KEY_EXPAND 255
#define KEY_HMAC_MD5 157
#define KEY_HMAC_SHA1 158
#define UNKNOWN_KEYALG 0
#define DST_MAX_ALGS KEY_HMAC_SHA1
/* DST constants to locations in KEY record changes in new KEY record */
#define DST_FLAGS_SIZE 2
#define DST_KEY_PROT 2
#define DST_KEY_ALG 3
#define DST_EXT_FLAG 4
#define DST_KEY_START 4
#ifndef SIGN_F_NOKEY
#define SIGN_F_NOKEY 0xC000
#endif
/* error codes from dst routines */
#define SIGN_INIT_FAILURE (-23)
#define SIGN_UPDATE_FAILURE (-24)
#define SIGN_FINAL_FAILURE (-25)
#define VERIFY_INIT_FAILURE (-26)
#define VERIFY_UPDATE_FAILURE (-27)
#define VERIFY_FINAL_FAILURE (-28)
#define MISSING_KEY_OR_SIGNATURE (-30)
#define UNSUPPORTED_KEYALG (-31)
#endif /* DST_H */
/*! \file */

View File

@ -1,24 +1,24 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-1999 by Internet Software Consortium
* Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1995-1999, 2001, 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* eventlib.h - exported interfaces for eventlib
* vix 09sep95 [initial]
*
* $Id: eventlib.h,v 1.3.18.3 2008/01/23 02:12:01 marka Exp $
* $Id: eventlib.h,v 1.7 2008/11/14 02:36:51 marka Exp $
*/
#ifndef _EVENTLIB_H

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1997,1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
typedef int (*heap_higher_priority_func)(void *, void *);
typedef void (*heap_index_func)(void *, int);
typedef void (*heap_for_each_func)(void *, void *);
typedef struct heap_context {
int array_size;
int array_size_increment;
int heap_size;
void **heap;
heap_higher_priority_func higher_priority;
heap_index_func index;
} *heap_context;
#define heap_new __heap_new
#define heap_free __heap_free
#define heap_insert __heap_insert
#define heap_delete __heap_delete
#define heap_increased __heap_increased
#define heap_decreased __heap_decreased
#define heap_element __heap_element
#define heap_for_each __heap_for_each
heap_context heap_new(heap_higher_priority_func, heap_index_func, int);
int heap_free(heap_context);
int heap_insert(heap_context, void *);
int heap_delete(heap_context, int);
int heap_increased(heap_context, int);
int heap_decreased(heap_context, int);
void * heap_element(heap_context, int);
int heap_for_each(heap_context, heap_for_each_func, void *);
/*! \file */

View File

@ -31,7 +31,8 @@
} while (0)
#define INIT_LINK(elt, link) \
INIT_LINK_TYPE(elt, link, void)
#define LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1))
#define LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1) && \
(void *)((elt)->link.next) != (void *)(-1))
#define HEAD(list) ((list).head)
#define TAIL(list) ((list).tail)

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1997,1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef MEMCLUSTER_H
#define MEMCLUSTER_H
#include <stdio.h>
#define meminit __meminit
#ifdef MEMCLUSTER_DEBUG
#define memget(s) __memget_debug(s, __FILE__, __LINE__)
#define memput(p, s) __memput_debug(p, s, __FILE__, __LINE__)
#else /*MEMCLUSTER_DEBUG*/
#ifdef MEMCLUSTER_RECORD
#define memget(s) __memget_record(s, __FILE__, __LINE__)
#define memput(p, s) __memput_record(p, s, __FILE__, __LINE__)
#else /*MEMCLUSTER_RECORD*/
#define memget __memget
#define memput __memput
#endif /*MEMCLUSTER_RECORD*/
#endif /*MEMCLUSTER_DEBUG*/
#define memstats __memstats
#define memactive __memactive
int meminit(size_t, size_t);
void * __memget(size_t);
void __memput(void *, size_t);
void * __memget_debug(size_t, const char *, int);
void __memput_debug(void *, size_t, const char *, int);
void * __memget_record(size_t, const char *, int);
void __memput_record(void *, size_t, const char *, int);
void memstats(FILE *);
int memactive(void);
#endif /* MEMCLUSTER_H */
/*! \file */

View File

@ -70,7 +70,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
static const char rcsid[] = "$Id: inet_addr.c,v 1.4.18.1 2005/04/27 05:00:52 sra Exp $";
static const char rcsid[] = "$Id: inet_addr.c,v 1.5 2005/04/27 04:56:19 sra Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_cidr_ntop.c,v 1.4.18.3 2006/10/11 02:32:47 marka Exp $";
static const char rcsid[] = "$Id: inet_cidr_ntop.c,v 1.7 2006/10/11 02:18:18 marka Exp $";
#endif
#include "port_before.h"

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_cidr_pton.c,v 1.5.18.1 2005/04/27 05:00:53 sra Exp $";
static const char rcsid[] = "$Id: inet_cidr_pton.c,v 1.6 2005/04/27 04:56:19 sra Exp $";
#endif
#include "port_before.h"

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.3.18.2 2006/06/20 02:51:32 marka Exp $";
static const char rcsid[] = "$Id: inet_net_ntop.c,v 1.5 2006/06/20 02:50:14 marka Exp $";
#endif
#include "port_before.h"

View File

@ -1,22 +1,22 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996,1999 by Internet Software Consortium.
* Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1996, 1998, 1999, 2001, 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_net_pton.c,v 1.7.18.2 2008/08/26 04:42:43 marka Exp $";
static const char rcsid[] = "$Id: inet_net_pton.c,v 1.10 2008/11/14 02:36:51 marka Exp $";
#endif
#include "port_before.h"

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_neta.c,v 1.2.18.1 2005/04/27 05:00:53 sra Exp $";
static const char rcsid[] = "$Id: inet_neta.c,v 1.3 2005/04/27 04:56:20 sra Exp $";
#endif
#include "port_before.h"

View File

@ -33,7 +33,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: inet_ntoa.c,v 1.1.352.1 2005/04/27 05:00:54 sra Exp $";
static const char rcsid[] = "$Id: inet_ntoa.c,v 1.2 2005/04/27 04:56:21 sra Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_ntop.c,v 1.3.18.2 2005/11/03 23:02:22 marka Exp $";
static const char rcsid[] = "$Id: inet_ntop.c,v 1.5 2005/11/03 22:59:52 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_pton.c,v 1.3.18.2 2005/07/28 07:38:07 marka Exp $";
static const char rcsid[] = "$Id: inet_pton.c,v 1.5 2005/07/28 06:51:47 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: nsap_addr.c,v 1.3.18.2 2005/07/28 07:38:08 marka Exp $";
static const char rcsid[] = "$Id: nsap_addr.c,v 1.5 2005/07/28 06:51:48 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"

94
lib/libc/isc/assertions.c Normal file
View File

@ -0,0 +1,94 @@
/*
* Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1997, 1999, 2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: assertions.c,v 1.5 2008/11/14 02:36:51 marka Exp $";
#endif
#include "port_before.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <isc/assertions.h>
#include "port_after.h"
/*
* Forward.
*/
static void default_assertion_failed(const char *, int, assertion_type,
const char *, int);
/*
* Public.
*/
assertion_failure_callback __assertion_failed = default_assertion_failed;
void
set_assertion_failure_callback(assertion_failure_callback f) {
if (f == NULL)
__assertion_failed = default_assertion_failed;
else
__assertion_failed = f;
}
const char *
assertion_type_to_text(assertion_type type) {
const char *result;
switch (type) {
case assert_require:
result = "REQUIRE";
break;
case assert_ensure:
result = "ENSURE";
break;
case assert_insist:
result = "INSIST";
break;
case assert_invariant:
result = "INVARIANT";
break;
default:
result = NULL;
}
return (result);
}
/*
* Private.
*/
/* coverity[+kill] */
static void
default_assertion_failed(const char *file, int line, assertion_type type,
const char *cond, int print_errno)
{
fprintf(stderr, "%s:%d: %s(%s)%s%s failed.\n",
file, line, assertion_type_to_text(type), cond,
(print_errno) ? ": " : "",
(print_errno) ? strerror(errno) : "");
abort();
/* NOTREACHED */
}
/*! \file */

View File

@ -0,0 +1,138 @@
.\" $Id: assertions.mdoc,v 1.3 2004/03/09 06:30:06 marka Exp $
.\"
.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1997,1999 by Internet Software Consortium.
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd November 17, 1997
.Dt ASSERTIONS 3
.Os ISC
.Sh NAME
.Nm REQUIRE ,
.Nm REQUIRE_ERR ,
.Nm ENSURE ,
.Nm ENSURE_ERR ,
.Nm INSIST ,
.Nm INSIST_ERR ,
.Nm INVARIANT ,
.Nm INVARIANT_ERR ,
.Nm set_assertion_failure_callback
.Nd assertion system
.Sh SYNOPSIS
.Fd #include <isc/assertions.h>
.Fo "typedef void (*assertion_failure_callback)"
.Fa "char *filename"
.Fa "int line"
.Fa "assertion_type type"
.Fa "char *condition"
.Fa "int print_errno"
.Fc
.Fn REQUIRE "int boolean_expression"
.Fn REQUIRE_ERR "int boolean_expression"
.Fn ENSURE "int boolean_expression"
.Fn ENSURE_ERR "int boolean_expression"
.Fn INSIST "int boolean_expression"
.Fn INSIST_ERR "int boolean_expression"
.Fn INVARIANT "int boolean_expression"
.Fn INVARIANT_ERR "int boolean_expression"
.Ft void
.Fn set_assertion_failure_callback "assertion_failure_callback callback"
.Ft char *
.Fn assertion_type_to_text "assertion_type type"
.Sh DESCRIPTION
The
.Fn REQUIRE ,
.Fn ENSURE ,
.Fn INSIST ,
and
.Fn INVARIANT
macros evaluate a boolean expression, and if it is false, they invoke the
current assertion failure callback. The default callback will print a message
to
.Li stderr
describing the failure, and then cause the program to dump core.
If the
.Dq Fn _ERR
variant of the assertion is used, the callback will include
.Fn strerror "errno"
in its message.
.Pp
Each assertion type has an associated
.Li CHECK
macro. If this macro's value is
.Dq 0
when
.Dq "<isc/assertions.h>"
is included, then assertions of that type will not be checked. E.g.
.Pp
.Dl #define CHECK_ENSURE 0
.Pp
will disable checking of
.Fn ENSURE
and
.Fn ENSURE_ERR .
The macros
.Li CHECK_ALL
and
.Li CHECK_NONE
may also be used, respectively specifying that either all or none of the
assertion types should be checked.
.Pp
.Fn set_assertion_failure_callback
specifies the function to call when an assertion fails.
.Pp
When an
.Fn assertion_failure_callback
is called, the
.Fa filename
and
.Fa line
arguments specify the filename and line number of the failing assertion.
The
.Fa type
is one of:
.Bd -literal -offset indent
assert_require
assert_ensure
assert_insist
assert_invariant
.Ed
.Pp
and may be used by the callback to determine the type of the failing
assertion.
.Fa condition
is the literal text of the assertion that failed.
.Fa print_errno
will be non-zero if the callback should print
.Fa strerror "errno"
as part of its output.
.Pp
.Fn assertion_type_to_text
returns a textual representation of
.Fa type .
For example,
.Fn assertion_type_to_text "assert_require"
returns the string
.Dq REQUIRE .
.Sh SEE ALSO
.Rs
.%A Bertrand Meyer
.%B Object-Oriented Software Construction, 2nd edition
.%Q Prentice\-Hall
.%D 1997
.%O ISBN 0\-13\-629155\-4
.%P chapter 11
.Re
.Sh AUTHOR
Bob Halley (ISC).

View File

@ -20,7 +20,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: ev_streams.c,v 1.4.18.1 2005/04/27 05:01:06 sra Exp $";
static const char rcsid[] = "$Id: ev_streams.c,v 1.5 2005/04/27 04:56:36 sra Exp $";
#endif
#include "port_before.h"

View File

@ -20,7 +20,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: ev_timers.c,v 1.5.18.1 2005/04/27 05:01:06 sra Exp $";
static const char rcsid[] = "$Id: ev_timers.c,v 1.6 2005/04/27 04:56:36 sra Exp $";
#endif
/* Import. */

View File

@ -19,7 +19,7 @@
* \brief private interfaces for eventlib
* \author vix 09sep95 [initial]
*
* $Id: eventlib_p.h,v 1.5.18.4 2006/03/10 00:20:08 marka Exp $
* $Id: eventlib_p.h,v 1.9 2006/03/09 23:57:56 marka Exp $
*/
#ifndef _EVENTLIB_P_H

View File

@ -16,7 +16,7 @@
*/
#ifndef lint
static const char rcsid[] = "$Id: ns_name.c,v 1.8.18.2 2005/04/27 05:01:08 sra Exp $";
static const char rcsid[] = "$Id: ns_name.c,v 1.11 2009/01/23 19:59:16 each Exp $";
#endif
#include "port_before.h"
@ -121,7 +121,7 @@ ns_name_ntop(const u_char *src, char *dst, size_t dstsiz)
}
if ((l = labellen(cp - 1)) < 0) {
errno = EMSGSIZE; /*%< XXX */
return(-1);
return (-1);
}
if (dn + l >= eom) {
errno = EMSGSIZE;
@ -133,12 +133,12 @@ ns_name_ntop(const u_char *src, char *dst, size_t dstsiz)
if (n != DNS_LABELTYPE_BITSTRING) {
/* XXX: labellen should reject this case */
errno = EINVAL;
return(-1);
return (-1);
}
if ((m = decode_bitstring(&cp, dn, eom)) < 0)
{
errno = EMSGSIZE;
return(-1);
return (-1);
}
dn += m;
continue;
@ -197,10 +197,25 @@ ns_name_ntop(const u_char *src, char *dst, size_t dstsiz)
* notes:
*\li Enforces label and domain length limits.
*/
int
ns_name_pton(const char *src, u_char *dst, size_t dstsiz)
{
ns_name_pton(const char *src, u_char *dst, size_t dstsiz) {
return (ns_name_pton2(src, dst, dstsiz, NULL));
}
/*
* ns_name_pton2(src, dst, dstsiz, *dstlen)
* Convert a ascii string into an encoded domain name as per RFC1035.
* return:
* -1 if it fails
* 1 if string was fully qualified
* 0 is string was not fully qualified
* side effects:
* fills in *dstlen (if non-NULL)
* notes:
* Enforces label and domain length limits.
*/
int
ns_name_pton2(const char *src, u_char *dst, size_t dstsiz, size_t *dstlen) {
u_char *label, *bp, *eom;
int c, n, escaped, e = 0;
char *cp;
@ -215,13 +230,13 @@ ns_name_pton(const char *src, u_char *dst, size_t dstsiz)
if (c == '[') { /*%< start a bit string label */
if ((cp = strchr(src, ']')) == NULL) {
errno = EINVAL; /*%< ??? */
return(-1);
return (-1);
}
if ((e = encode_bitsring(&src, cp + 2,
&label, &bp, eom))
!= 0) {
errno = e;
return(-1);
return (-1);
}
escaped = 0;
label = bp++;
@ -229,7 +244,7 @@ ns_name_pton(const char *src, u_char *dst, size_t dstsiz)
goto done;
else if (c != '.') {
errno = EINVAL;
return(-1);
return (-1);
}
continue;
}
@ -281,6 +296,8 @@ ns_name_pton(const char *src, u_char *dst, size_t dstsiz)
errno = EMSGSIZE;
return (-1);
}
if (dstlen != NULL)
*dstlen = (bp - dst);
return (1);
}
if (c == 0 || *src == '.') {
@ -318,6 +335,8 @@ ns_name_pton(const char *src, u_char *dst, size_t dstsiz)
errno = EMSGSIZE;
return (-1);
}
if (dstlen != NULL)
*dstlen = (bp - dst);
return (0);
}
@ -365,7 +384,7 @@ ns_name_ntol(const u_char *src, u_char *dst, size_t dstsiz)
}
for ((void)NULL; l > 0; l--) {
c = *cp++;
if (isupper(c))
if (isascii(c) && isupper(c))
*dn++ = tolower(c);
else
*dn++ = c;
@ -384,6 +403,21 @@ ns_name_ntol(const u_char *src, u_char *dst, size_t dstsiz)
int
ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src,
u_char *dst, size_t dstsiz)
{
return (ns_name_unpack2(msg, eom, src, dst, dstsiz, NULL));
}
/*
* ns_name_unpack2(msg, eom, src, dst, dstsiz, *dstlen)
* Unpack a domain name from a message, source may be compressed.
* return:
* -1 if it fails, or consumed octets if it succeeds.
* side effect:
* fills in *dstlen (if non-NULL).
*/
int
ns_name_unpack2(const u_char *msg, const u_char *eom, const u_char *src,
u_char *dst, size_t dstsiz, size_t *dstlen)
{
const u_char *srcp, *dstlim;
u_char *dstp;
@ -407,7 +441,7 @@ ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src,
/* Limit checks. */
if ((l = labellen(srcp - 1)) < 0) {
errno = EMSGSIZE;
return(-1);
return (-1);
}
if (dstp + l + 1 >= dstlim || srcp + l >= eom) {
errno = EMSGSIZE;
@ -449,7 +483,9 @@ ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src,
return (-1); /*%< flag error */
}
}
*dstp = '\0';
*dstp++ = 0;
if (dstlen != NULL)
*dstlen = dstp - dst;
if (len < 0)
len = srcp - src;
return (len);
@ -508,7 +544,7 @@ ns_name_pack(const u_char *src, u_char *dst, int dstsiz,
}
if ((l0 = labellen(srcp)) < 0) {
errno = EINVAL;
return(-1);
return (-1);
}
l += l0 + 1;
if (l > MAXCDNAME) {
@ -655,7 +691,7 @@ ns_name_skip(const u_char **ptrptr, const u_char *eom)
case NS_TYPE_ELT: /*%< EDNS0 extended label */
if ((l = labellen(cp - 1)) < 0) {
errno = EMSGSIZE; /*%< XXX */
return(-1);
return (-1);
}
cp += l;
continue;
@ -676,6 +712,150 @@ ns_name_skip(const u_char **ptrptr, const u_char *eom)
return (0);
}
/* Find the number of octets an nname takes up, including the root label.
* (This is basically ns_name_skip() without compression-pointer support.)
* ((NOTE: can only return zero if passed-in namesiz argument is zero.))
*/
ssize_t
ns_name_length(ns_nname_ct nname, size_t namesiz) {
ns_nname_ct orig = nname;
u_int n;
while (namesiz-- > 0 && (n = *nname++) != 0) {
if ((n & NS_CMPRSFLGS) != 0) {
errno = EISDIR;
return (-1);
}
if (n > namesiz) {
errno = EMSGSIZE;
return (-1);
}
nname += n;
namesiz -= n;
}
return (nname - orig);
}
/* Compare two nname's for equality. Return -1 on error (setting errno).
*/
int
ns_name_eq(ns_nname_ct a, size_t as, ns_nname_ct b, size_t bs) {
ns_nname_ct ae = a + as, be = b + bs;
int ac, bc;
while (ac = *a, bc = *b, ac != 0 && bc != 0) {
if ((ac & NS_CMPRSFLGS) != 0 || (bc & NS_CMPRSFLGS) != 0) {
errno = EISDIR;
return (-1);
}
if (a + ac >= ae || b + bc >= be) {
errno = EMSGSIZE;
return (-1);
}
if (ac != bc || strncasecmp((const char *) ++a,
(const char *) ++b, ac) != 0)
return (0);
a += ac, b += bc;
}
return (ac == 0 && bc == 0);
}
/* Is domain "A" owned by (at or below) domain "B"?
*/
int
ns_name_owned(ns_namemap_ct a, int an, ns_namemap_ct b, int bn) {
/* If A is shorter, it cannot be owned by B. */
if (an < bn)
return (0);
/* If they are unequal before the length of the shorter, A cannot... */
while (bn > 0) {
if (a->len != b->len ||
strncasecmp((const char *) a->base,
(const char *) b->base, a->len) != 0)
return (0);
a++, an--;
b++, bn--;
}
/* A might be longer or not, but either way, B owns it. */
return (1);
}
/* Build an array of <base,len> tuples from an nname, top-down order.
* Return the number of tuples (labels) thus discovered.
*/
int
ns_name_map(ns_nname_ct nname, size_t namelen, ns_namemap_t map, int mapsize) {
u_int n;
int l;
n = *nname++;
namelen--;
/* Root zone? */
if (n == 0) {
/* Extra data follows name? */
if (namelen > 0) {
errno = EMSGSIZE;
return (-1);
}
return (0);
}
/* Compression pointer? */
if ((n & NS_CMPRSFLGS) != 0) {
errno = EISDIR;
return (-1);
}
/* Label too long? */
if (n > namelen) {
errno = EMSGSIZE;
return (-1);
}
/* Recurse to get rest of name done first. */
l = ns_name_map(nname + n, namelen - n, map, mapsize);
if (l < 0)
return (-1);
/* Too many labels? */
if (l >= mapsize) {
errno = ENAMETOOLONG;
return (-1);
}
/* We're on our way back up-stack, store current map data. */
map[l].base = nname;
map[l].len = n;
return (l + 1);
}
/* Count the labels in a domain name. Root counts, so COM. has two. This
* is to make the result comparable to the result of ns_name_map().
*/
int
ns_name_labels(ns_nname_ct nname, size_t namesiz) {
int ret = 0;
u_int n;
while (namesiz-- > 0 && (n = *nname++) != 0) {
if ((n & NS_CMPRSFLGS) != 0) {
errno = EISDIR;
return (-1);
}
if (n > namesiz) {
errno = EMSGSIZE;
return (-1);
}
nname += n;
namesiz -= n;
ret++;
}
return (ret + 1);
}
/* Private. */
/*%
@ -806,7 +986,7 @@ decode_bitstring(const unsigned char **cpp, char *dn, const char *eom)
plen = (blen + 3) / 4;
plen += sizeof("\\[x/]") + (blen > 99 ? 3 : (blen > 9) ? 2 : 1);
if (dn + plen >= eom)
return(-1);
return (-1);
cp++;
i = SPRINTF((dn, "\\[x"));
@ -839,12 +1019,12 @@ decode_bitstring(const unsigned char **cpp, char *dn, const char *eom)
dn += i;
*cpp = cp;
return(dn - beg);
return (dn - beg);
}
static int
encode_bitsring(const char **bp, const char *end, unsigned char **labelp,
unsigned char ** dst, unsigned const char *eom)
unsigned char ** dst, unsigned const char *eom)
{
int afterslash = 0;
const char *cp = *bp;
@ -858,23 +1038,23 @@ encode_bitsring(const char **bp, const char *end, unsigned char **labelp,
/* a bitstring must contain at least 2 characters */
if (end - cp < 2)
return(EINVAL);
return (EINVAL);
/* XXX: currently, only hex strings are supported */
if (*cp++ != 'x')
return(EINVAL);
return (EINVAL);
if (!isxdigit((*cp) & 0xff)) /*%< reject '\[x/BLEN]' */
return(EINVAL);
return (EINVAL);
for (tp = *dst + 1; cp < end && tp < eom; cp++) {
switch((c = *cp)) {
case ']': /*%< end of the bitstring */
if (afterslash) {
if (beg_blen == NULL)
return(EINVAL);
return (EINVAL);
blen = (int)strtol(beg_blen, &end_blen, 10);
if (*end_blen != ']')
return(EINVAL);
return (EINVAL);
}
if (count)
*tp++ = ((value << 4) & 0xff);
@ -886,24 +1066,24 @@ encode_bitsring(const char **bp, const char *end, unsigned char **labelp,
default:
if (afterslash) {
if (!isdigit(c&0xff))
return(EINVAL);
return (EINVAL);
if (beg_blen == NULL) {
if (c == '0') {
/* blen never begings with 0 */
return(EINVAL);
return (EINVAL);
}
beg_blen = cp;
}
} else {
if (!isxdigit(c&0xff))
return(EINVAL);
return (EINVAL);
value <<= 4;
value += digitvalue[(int)c];
count += 4;
tbcount += 4;
if (tbcount > 256)
return(EINVAL);
return (EINVAL);
if (count == 8) {
*tp++ = value;
count = 0;
@ -914,7 +1094,7 @@ encode_bitsring(const char **bp, const char *end, unsigned char **labelp,
}
done:
if (cp >= end || tp >= eom)
return(EMSGSIZE);
return (EMSGSIZE);
/*
* bit length validation:
@ -928,10 +1108,10 @@ encode_bitsring(const char **bp, const char *end, unsigned char **labelp,
int traillen;
if (((blen + 3) & ~3) != tbcount)
return(EINVAL);
return (EINVAL);
traillen = tbcount - blen; /*%< between 0 and 3 */
if (((value << (8 - traillen)) & 0xff) != 0)
return(EINVAL);
return (EINVAL);
}
else
blen = tbcount;
@ -945,7 +1125,7 @@ encode_bitsring(const char **bp, const char *end, unsigned char **labelp,
*bp = cp;
*dst = tp;
return(0);
return (0);
}
static int
@ -956,18 +1136,18 @@ labellen(const u_char *lp)
if ((l & NS_CMPRSFLGS) == NS_CMPRSFLGS) {
/* should be avoided by the caller */
return(-1);
return (-1);
}
if ((l & NS_CMPRSFLGS) == NS_TYPE_ELT) {
if (l == DNS_LABELTYPE_BITSTRING) {
if ((bitlen = *(lp + 1)) == 0)
bitlen = 256;
return((bitlen + 7 ) / 8 + 1);
return ((bitlen + 7 ) / 8 + 1);
}
return(-1); /*%< unknwon ELT */
return (-1); /*%< unknwon ELT */
}
return(l);
return (l);
}
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#ifndef lint
static const char rcsid[] = "$Id: ns_netint.c,v 1.2.18.1 2005/04/27 05:01:08 sra Exp $";
static const char rcsid[] = "$Id: ns_netint.c,v 1.3 2005/04/27 04:56:40 sra Exp $";
#endif
/* Import. */

View File

@ -16,7 +16,7 @@
*/
#ifndef lint
static const char rcsid[] = "$Id: ns_parse.c,v 1.5.18.4 2007/08/27 03:34:24 marka Exp $";
static const char rcsid[] = "$Id: ns_parse.c,v 1.10 2009/01/23 19:59:16 each Exp $";
#endif
/* Import. */
@ -47,6 +47,9 @@ static void setsection(ns_msg *msg, ns_sect sect);
do { errno = (err); if (errno == errno) return (-1); } while (0)
#endif
#define PARSE_FMT_PRESO 0 /* Parse using presentation-format names */
#define PARSE_FMT_WIRE 1 /* Parse using network-format names */
/* Public. */
/* These need to be in the same order as the nres.h:ns_flag enum. */
@ -102,7 +105,6 @@ ns_initparse(const u_char *msg, int msglen, ns_msg *handle) {
const u_char *eom = msg + msglen;
int i;
memset(handle, 0x5e, sizeof *handle);
handle->_msg = msg;
handle->_eom = eom;
if (msg + NS_INT16SZ > eom)
@ -194,6 +196,68 @@ ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) {
return (0);
}
/*
* This is identical to the above but uses network-format (uncompressed) names.
*/
int
ns_parserr2(ns_msg *handle, ns_sect section, int rrnum, ns_rr2 *rr) {
int b;
int tmp;
/* Make section right. */
if ((tmp = section) < 0 || section >= ns_s_max)
RETERR(ENODEV);
if (section != handle->_sect)
setsection(handle, section);
/* Make rrnum right. */
if (rrnum == -1)
rrnum = handle->_rrnum;
if (rrnum < 0 || rrnum >= handle->_counts[(int)section])
RETERR(ENODEV);
if (rrnum < handle->_rrnum)
setsection(handle, section);
if (rrnum > handle->_rrnum) {
b = ns_skiprr(handle->_msg_ptr, handle->_eom, section,
rrnum - handle->_rrnum);
if (b < 0)
return (-1);
handle->_msg_ptr += b;
handle->_rrnum = rrnum;
}
/* Do the parse. */
b = ns_name_unpack2(handle->_msg, handle->_eom, handle->_msg_ptr,
rr->nname, NS_MAXNNAME, &rr->nnamel);
if (b < 0)
return (-1);
handle->_msg_ptr += b;
if (handle->_msg_ptr + NS_INT16SZ + NS_INT16SZ > handle->_eom)
RETERR(EMSGSIZE);
NS_GET16(rr->type, handle->_msg_ptr);
NS_GET16(rr->rr_class, handle->_msg_ptr);
if (section == ns_s_qd) {
rr->ttl = 0;
rr->rdlength = 0;
rr->rdata = NULL;
} else {
if (handle->_msg_ptr + NS_INT32SZ + NS_INT16SZ > handle->_eom)
RETERR(EMSGSIZE);
NS_GET32(rr->ttl, handle->_msg_ptr);
NS_GET16(rr->rdlength, handle->_msg_ptr);
if (handle->_msg_ptr + rr->rdlength > handle->_eom)
RETERR(EMSGSIZE);
rr->rdata = handle->_msg_ptr;
handle->_msg_ptr += rr->rdlength;
}
if (++handle->_rrnum > handle->_counts[(int)section])
setsection(handle, (ns_sect)((int)section + 1));
/* All done. */
return (0);
}
/* Private. */
static void

View File

@ -16,7 +16,7 @@
*/
#ifndef lint
static const char rcsid[] = "$Id: ns_print.c,v 1.6.18.4 2005/04/27 05:01:09 sra Exp $";
static const char rcsid[] = "$Id: ns_print.c,v 1.12 2009/03/03 05:29:58 each Exp $";
#endif
/* Import. */
@ -67,6 +67,9 @@ static int addtab(size_t len, size_t target, int spaced,
return (-1); \
} while (0)
static const char base32hex[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUV=0123456789abcdefghijklmnopqrstuv";
/* Public. */
/*%
@ -250,7 +253,8 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
case ns_t_mx:
case ns_t_afsdb:
case ns_t_rt: {
case ns_t_rt:
case ns_t_kx: {
u_int t;
if (rdlen < (size_t)NS_INT16SZ)
@ -298,6 +302,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
break;
case ns_t_txt:
case ns_t_spf:
while (rdata < edata) {
T(len = charstr(rdata, edata, &buf, &buflen));
if (len == 0)
@ -444,7 +449,8 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
break;
}
case ns_t_key: {
case ns_t_key:
case ns_t_dnskey: {
char base64_key[NS_MD5RSA_MAX_BASE64];
u_int keyflags, protocol, algorithm, key_id;
const char *leader;
@ -486,7 +492,8 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
break;
}
case ns_t_sig: {
case ns_t_sig:
case ns_t_rrsig: {
char base64_key[NS_MD5RSA_MAX_BASE64];
u_int type, algorithm, labels, footprint;
const char *leader;
@ -497,7 +504,7 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
goto formerr;
/* Type covered, Algorithm, Label count, Original TTL. */
type = ns_get16(rdata); rdata += NS_INT16SZ;
type = ns_get16(rdata); rdata += NS_INT16SZ;
algorithm = *rdata++;
labels = *rdata++;
t = ns_get32(rdata); rdata += NS_INT32SZ;
@ -691,6 +698,344 @@ ns_sprintrrf(const u_char *msg, size_t msglen,
break;
}
case ns_t_ds:
case ns_t_dlv:
case ns_t_sshfp: {
u_int t;
if (type == ns_t_ds || type == ns_t_dlv) {
if (rdlen < 4U) goto formerr;
t = ns_get16(rdata);
rdata += NS_INT16SZ;
len = SPRINTF((tmp, "%u ", t));
T(addstr(tmp, len, &buf, &buflen));
} else
if (rdlen < 2U) goto formerr;
len = SPRINTF((tmp, "%u ", *rdata));
T(addstr(tmp, len, &buf, &buflen));
rdata++;
len = SPRINTF((tmp, "%u ", *rdata));
T(addstr(tmp, len, &buf, &buflen));
rdata++;
while (rdata < edata) {
len = SPRINTF((tmp, "%02X", *rdata));
T(addstr(tmp, len, &buf, &buflen));
rdata++;
}
break;
}
case ns_t_nsec3:
case ns_t_nsec3param: {
u_int t, w, l, j, k, c;
len = SPRINTF((tmp, "%u ", *rdata));
T(addstr(tmp, len, &buf, &buflen));
rdata++;
len = SPRINTF((tmp, "%u ", *rdata));
T(addstr(tmp, len, &buf, &buflen));
rdata++;
t = ns_get16(rdata);
rdata += NS_INT16SZ;
len = SPRINTF((tmp, "%u ", t));
T(addstr(tmp, len, &buf, &buflen));
t = *rdata++;
if (t == 0) {
T(addstr("-", 1, &buf, &buflen));
} else {
while (t-- > 0) {
len = SPRINTF((tmp, "%02X", *rdata));
T(addstr(tmp, len, &buf, &buflen));
rdata++;
}
}
if (type == ns_t_nsec3param)
break;
T(addstr(" ", 1, &buf, &buflen));
t = *rdata++;
while (t > 0) {
switch (t) {
case 1:
tmp[0] = base32hex[((rdata[0]>>3)&0x1f)];
tmp[1] = base32hex[((rdata[0]<<2)&0x1c)];
tmp[2] = tmp[3] = tmp[4] = '=';
tmp[5] = tmp[6] = tmp[7] = '=';
break;
case 2:
tmp[0] = base32hex[((rdata[0]>>3)&0x1f)];
tmp[1] = base32hex[((rdata[0]<<2)&0x1c)|
((rdata[1]>>6)&0x03)];
tmp[2] = base32hex[((rdata[1]>>1)&0x1f)];
tmp[3] = base32hex[((rdata[1]<<4)&0x10)];
tmp[4] = tmp[5] = tmp[6] = tmp[7] = '=';
break;
case 3:
tmp[0] = base32hex[((rdata[0]>>3)&0x1f)];
tmp[1] = base32hex[((rdata[0]<<2)&0x1c)|
((rdata[1]>>6)&0x03)];
tmp[2] = base32hex[((rdata[1]>>1)&0x1f)];
tmp[3] = base32hex[((rdata[1]<<4)&0x10)|
((rdata[2]>>4)&0x0f)];
tmp[4] = base32hex[((rdata[2]<<1)&0x1e)];
tmp[5] = tmp[6] = tmp[7] = '=';
break;
case 4:
tmp[0] = base32hex[((rdata[0]>>3)&0x1f)];
tmp[1] = base32hex[((rdata[0]<<2)&0x1c)|
((rdata[1]>>6)&0x03)];
tmp[2] = base32hex[((rdata[1]>>1)&0x1f)];
tmp[3] = base32hex[((rdata[1]<<4)&0x10)|
((rdata[2]>>4)&0x0f)];
tmp[4] = base32hex[((rdata[2]<<1)&0x1e)|
((rdata[3]>>7)&0x01)];
tmp[5] = base32hex[((rdata[3]>>2)&0x1f)];
tmp[6] = base32hex[(rdata[3]<<3)&0x18];
tmp[7] = '=';
break;
default:
tmp[0] = base32hex[((rdata[0]>>3)&0x1f)];
tmp[1] = base32hex[((rdata[0]<<2)&0x1c)|
((rdata[1]>>6)&0x03)];
tmp[2] = base32hex[((rdata[1]>>1)&0x1f)];
tmp[3] = base32hex[((rdata[1]<<4)&0x10)|
((rdata[2]>>4)&0x0f)];
tmp[4] = base32hex[((rdata[2]<<1)&0x1e)|
((rdata[3]>>7)&0x01)];
tmp[5] = base32hex[((rdata[3]>>2)&0x1f)];
tmp[6] = base32hex[((rdata[3]<<3)&0x18)|
((rdata[4]>>5)&0x07)];
tmp[7] = base32hex[(rdata[4]&0x1f)];
break;
}
T(addstr(tmp, 8, &buf, &buflen));
if (t >= 5) {
rdata += 5;
t -= 5;
} else {
rdata += t;
t -= t;
}
}
while (rdata < edata) {
w = *rdata++;
l = *rdata++;
for (j = 0; j < l; j++) {
if (rdata[j] == 0)
continue;
for (k = 0; k < 8; k++) {
if ((rdata[j] & (0x80 >> k)) == 0)
continue;
c = w * 256 + j * 8 + k;
len = SPRINTF((tmp, " %s", p_type(c)));
T(addstr(tmp, len, &buf, &buflen));
}
}
rdata += l;
}
break;
}
case ns_t_nsec: {
u_int w, l, j, k, c;
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
while (rdata < edata) {
w = *rdata++;
l = *rdata++;
for (j = 0; j < l; j++) {
if (rdata[j] == 0)
continue;
for (k = 0; k < 8; k++) {
if ((rdata[j] & (0x80 >> k)) == 0)
continue;
c = w * 256 + j * 8 + k;
len = SPRINTF((tmp, " %s", p_type(c)));
T(addstr(tmp, len, &buf, &buflen));
}
}
rdata += l;
}
break;
}
case ns_t_dhcid: {
int n;
unsigned int siz;
char base64_dhcid[8192];
const char *leader;
siz = (edata-rdata)*4/3 + 4; /* "+4" accounts for trailing \0 */
if (siz > sizeof(base64_dhcid) * 3/4) {
const char *str = "record too long to print";
T(addstr(str, strlen(str), &buf, &buflen));
} else {
len = b64_ntop(rdata, edata-rdata, base64_dhcid, siz);
if (len < 0)
goto formerr;
else if (len > 15) {
T(addstr(" (", 2, &buf, &buflen));
leader = "\n\t\t";
spaced = 0;
}
else
leader = " ";
for (n = 0; n < len; n += 48) {
T(addstr(leader, strlen(leader),
&buf, &buflen));
T(addstr(base64_dhcid + n, MIN(len - n, 48),
&buf, &buflen));
}
if (len > 15)
T(addstr(" )", 2, &buf, &buflen));
}
}
case ns_t_ipseckey: {
int n;
unsigned int siz;
char base64_key[8192];
const char *leader;
if (rdlen < 2)
goto formerr;
switch (rdata[1]) {
case 0:
case 3:
if (rdlen < 3)
goto formerr;
break;
case 1:
if (rdlen < 7)
goto formerr;
break;
case 2:
if (rdlen < 19)
goto formerr;
break;
default:
comment = "unknown IPSECKEY gateway type";
goto hexify;
}
len = SPRINTF((tmp, "%u ", *rdata));
T(addstr(tmp, len, &buf, &buflen));
rdata++;
len = SPRINTF((tmp, "%u ", *rdata));
T(addstr(tmp, len, &buf, &buflen));
rdata++;
len = SPRINTF((tmp, "%u ", *rdata));
T(addstr(tmp, len, &buf, &buflen));
rdata++;
switch (rdata[-2]) {
case 0:
T(addstr(".", 1, &buf, &buflen));
break;
case 1:
(void) inet_ntop(AF_INET, rdata, buf, buflen);
addlen(strlen(buf), &buf, &buflen);
rdata += 4;
break;
case 2:
(void) inet_ntop(AF_INET6, rdata, buf, buflen);
addlen(strlen(buf), &buf, &buflen);
rdata += 16;
break;
case 3:
T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
break;
}
if (rdata >= edata)
break;
siz = (edata-rdata)*4/3 + 4; /* "+4" accounts for trailing \0 */
if (siz > sizeof(base64_key) * 3/4) {
const char *str = "record too long to print";
T(addstr(str, strlen(str), &buf, &buflen));
} else {
len = b64_ntop(rdata, edata-rdata, base64_key, siz);
if (len < 0)
goto formerr;
else if (len > 15) {
T(addstr(" (", 2, &buf, &buflen));
leader = "\n\t\t";
spaced = 0;
}
else
leader = " ";
for (n = 0; n < len; n += 48) {
T(addstr(leader, strlen(leader),
&buf, &buflen));
T(addstr(base64_key + n, MIN(len - n, 48),
&buf, &buflen));
}
if (len > 15)
T(addstr(" )", 2, &buf, &buflen));
}
}
case ns_t_hip: {
unsigned int i, hip_len, algorithm, key_len;
char base64_key[NS_MD5RSA_MAX_BASE64];
unsigned int siz;
const char *leader = "\n\t\t\t\t\t";
hip_len = *rdata++;
algorithm = *rdata++;
key_len = ns_get16(rdata);
rdata += NS_INT16SZ;
siz = key_len*4/3 + 4; /* "+4" accounts for trailing \0 */
if (siz > sizeof(base64_key) * 3/4) {
const char *str = "record too long to print";
T(addstr(str, strlen(str), &buf, &buflen));
} else {
len = sprintf(tmp, "( %u ", algorithm);
T(addstr(tmp, len, &buf, &buflen));
for (i = 0; i < hip_len; i++) {
len = sprintf(tmp, "%02X", *rdata);
T(addstr(tmp, len, &buf, &buflen));
rdata++;
}
T(addstr(leader, strlen(leader), &buf, &buflen));
len = b64_ntop(rdata, key_len, base64_key, siz);
if (len < 0)
goto formerr;
T(addstr(base64_key, len, &buf, &buflen));
rdata += key_len;
while (rdata < edata) {
T(addstr(leader, strlen(leader), &buf, &buflen));
T(addname(msg, msglen, &rdata, origin,
&buf, &buflen));
}
T(addstr(" )", 2, &buf, &buflen));
}
break;
}
default:
comment = "unknown RR type";
goto hexify;

View File

@ -16,7 +16,7 @@
*/
#ifndef lint
static const char rcsid[] = "$Id: ns_samedomain.c,v 1.5.18.1 2005/04/27 05:01:09 sra Exp $";
static const char rcsid[] = "$Id: ns_samedomain.c,v 1.6 2005/04/27 04:56:40 sra Exp $";
#endif
#include "port_before.h"

View File

@ -16,7 +16,7 @@
*/
#ifndef lint
static const char rcsid[] = "$Id: ns_ttl.c,v 1.2.18.2 2005/07/28 07:38:10 marka Exp $";
static const char rcsid[] = "$Id: ns_ttl.c,v 1.4 2005/07/28 06:51:49 marka Exp $";
#endif
/* Import. */

View File

@ -50,7 +50,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: herror.c,v 1.3.18.1 2005/04/27 05:01:09 sra Exp $";
static const char rcsid[] = "$Id: herror.c,v 1.4 2005/04/27 04:56:41 sra Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"

View File

@ -70,7 +70,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: res_comp.c,v 1.3.18.2 2005/07/28 07:38:11 marka Exp $";
static const char rcsid[] = "$Id: res_comp.c,v 1.5 2005/07/28 06:51:50 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: res_data.c,v 1.3.18.2 2007/09/14 05:35:47 marka Exp $";
static const char rcsid[] = "$Id: res_data.c,v 1.7 2008/12/11 09:59:00 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@ -120,7 +120,7 @@ res_init(void) {
* has set it to something in particular, we can randomize it now.
*/
if (!_res.id)
_res.id = res_randomid();
_res.id = res_nrandomid(&_res);
return (__res_vinit(&_res, 1));
}
@ -268,6 +268,16 @@ res_querydomain(const char *name,
answer, anslen));
}
u_int
res_randomid(void) {
if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
return (-1);
}
return (res_nrandomid(&_res));
}
const char *
hostalias(const char *name) {
static char abuf[MAXDNAME];

View File

@ -1,7 +1,24 @@
/*
* Portions Copyright (C) 2004, 2005, 2008, 2009 Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (C) 1996-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Copyright (c) 1985
* The Regents of the University of California. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -17,7 +34,7 @@
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -33,14 +50,14 @@
/*
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
@ -76,26 +93,9 @@
* IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: res_debug.c,v 1.10.18.6 2008/04/03 23:15:15 marka Exp $";
static const char rcsid[] = "$Id: res_debug.c,v 1.19 2009/02/26 11:20:20 tbox Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@ -329,7 +329,7 @@ res_pquery(const res_state statp, const u_char *msg, int len, FILE *file) {
fprintf(file, ", %s: %d",
p_section(ns_s_ar, opcode), arcount);
}
if ((!statp->pfcode) || (statp->pfcode &
if ((!statp->pfcode) || (statp->pfcode &
(RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1))) {
putc('\n',file);
}
@ -496,6 +496,24 @@ const struct res_sym __p_type_syms[] = {
{ns_t_nimloc, "NIMLOC", "NIMROD locator (unimplemented)"},
{ns_t_srv, "SRV", "server selection"},
{ns_t_atma, "ATMA", "ATM address (unimplemented)"},
{ns_t_naptr, "NAPTR", "naptr"},
{ns_t_kx, "KX", "key exchange"},
{ns_t_cert, "CERT", "certificate"},
{ns_t_a6, "A", "IPv6 address (experminental)"},
{ns_t_dname, "DNAME", "non-terminal redirection"},
{ns_t_opt, "OPT", "opt"},
{ns_t_apl, "apl", "apl"},
{ns_t_ds, "DS", "delegation signer"},
{ns_t_sshfp, "SSFP", "SSH fingerprint"},
{ns_t_ipseckey, "IPSECKEY", "IPSEC key"},
{ns_t_rrsig, "RRSIG", "rrsig"},
{ns_t_nsec, "NSEC", "nsec"},
{ns_t_dnskey, "DNSKEY", "DNS key"},
{ns_t_dhcid, "DHCID", "dynamic host configuration identifier"},
{ns_t_nsec3, "NSEC3", "nsec3"},
{ns_t_nsec3param, "NSEC3PARAM", "NSEC3 parameters"},
{ns_t_hip, "HIP", "host identity protocol"},
{ns_t_spf, "SPF", "sender policy framework"},
{ns_t_tkey, "TKEY", "tkey"},
{ns_t_tsig, "TSIG", "transaction signature"},
{ns_t_ixfr, "IXFR", "incremental zone transfer"},
@ -511,6 +529,7 @@ const struct res_sym __p_type_syms[] = {
{ns_t_sink, "SINK", "Kitchen Sink (experimental)"},
{ns_t_opt, "OPT", "EDNS Options"},
{ns_t_any, "ANY", "\"any\""},
{ns_t_dlv, "DLV", "DNSSEC look-aside validation"},
{0, NULL, NULL}
};
@ -938,7 +957,7 @@ loc_aton(ascii, binary)
altsign = -1;
cp++;
}
if (*cp == '+')
cp++;
@ -967,7 +986,7 @@ loc_aton(ascii, binary)
goto defaults;
siz = precsize_aton(&cp);
while (!isspace((unsigned char)*cp) && (cp < maxcp)) /*%< if trailing garbage or m */
cp++;
@ -1000,7 +1019,7 @@ loc_aton(ascii, binary)
PUTLONG(latit,bcp);
PUTLONG(longit,bcp);
PUTLONG(alt,bcp);
return (16); /*%< size of RR in octets */
}
@ -1026,7 +1045,7 @@ loc_ntoa(binary, ascii)
int32_t latval, longval, altval;
u_int32_t templ;
u_int8_t sizeval, hpval, vpval, versionval;
char *sizestr, *hpstr, *vpstr;
versionval = *cp++;
@ -1140,7 +1159,7 @@ dn_count_labels(const char *name) {
}
/*%
* Make dates expressed in seconds-since-Jan-1-1970 easy to read.
* Make dates expressed in seconds-since-Jan-1-1970 easy to read.
* SIG records are required to be printed like this, by the Secure DNS RFC.
*/
char *
@ -1150,7 +1169,7 @@ p_secstodate (u_long secs) {
struct tm *time;
#ifdef HAVE_TIME_R
struct tm res;
time = gmtime_r(&clock, &res);
#else
time = gmtime(&clock);

View File

@ -1,5 +1,5 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: res_findzonecut.c,v 1.7.18.3 2005/10/11 00:25:11 marka Exp $";
static const char rcsid[] = "$Id: res_findzonecut.c,v 1.10 2005/10/11 00:10:16 marka Exp $";
#endif /* not lint */
/*

View File

@ -70,7 +70,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
static const char rcsid[] = "$Id: res_init.c,v 1.16.18.7 2007/07/09 01:52:58 marka Exp $";
static const char rcsid[] = "$Id: res_init.c,v 1.26 2008/12/11 09:59:00 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@ -91,6 +91,17 @@ static const char rcsid[] = "$Id: res_init.c,v 1.16.18.7 2007/07/09 01:52:58 mar
#include <unistd.h>
#include <netdb.h>
#ifndef HAVE_MD5
# include "../dst/md5.h"
#else
# ifdef SOLARIS2
# include <sys/md5.h>
# endif
#endif
#ifndef _MD5_H_
# define _MD5_H_ 1 /*%< make sure we do not include rsaref md5.h file */
#endif
#include "port_after.h"
/* ensure that sockaddr_in6 and IN6ADDR_ANY_INIT are declared / defined */
@ -176,7 +187,8 @@ __res_vinit(res_state statp, int preinit) {
statp->retrans = RES_TIMEOUT;
statp->retry = RES_DFLRETRY;
statp->options = RES_DEFAULT;
statp->id = res_randomid();
res_rndinit(statp);
statp->id = res_nrandomid(statp);
}
memset(u, 0, sizeof(u));
@ -646,12 +658,44 @@ net_mask(in) /*!< XXX - should really use system's version of this */
}
#endif
u_int
res_randomid(void) {
void
res_rndinit(res_state statp)
{
struct timeval now;
u_int32_t u32;
u_int16_t u16;
gettimeofday(&now, NULL);
return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid()));
u32 = now.tv_sec;
memcpy(statp->_rnd, &u32, 4);
u32 = now.tv_usec;
memcpy(statp->_rnd + 4, &u32, 4);
u32 += now.tv_sec;
memcpy(statp->_rnd + 8, &u32, 4);
u16 = getpid();
memcpy(statp->_rnd + 12, &u16, 2);
}
u_int
res_nrandomid(res_state statp) {
struct timeval now;
u_int16_t u16;
MD5_CTX ctx;
gettimeofday(&now, NULL);
u16 = (u_int16_t) (now.tv_sec ^ now.tv_usec);
memcpy(statp->_rnd + 14, &u16, 2);
#ifndef HAVE_MD5
MD5_Init(&ctx);
MD5_Update(&ctx, statp->_rnd, 16);
MD5_Final(statp->_rnd, &ctx);
#else
MD5Init(&ctx);
MD5Update(&ctx, statp->_rnd, 16);
MD5Final(statp->_rnd, &ctx);
#endif
memcpy(&u16, statp->_rnd + 14, 2);
return ((u_int) u16);
}
/*%

View File

@ -1,7 +1,24 @@
/*
* Portions Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (C) 1996, 1997, 1988, 1999, 2001, 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -17,7 +34,7 @@
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -33,14 +50,14 @@
/*
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
@ -51,26 +68,9 @@
* SOFTWARE.
*/
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: res_mkquery.c,v 1.5.18.2 2008/04/03 23:15:15 marka Exp $";
static const char rcsid[] = "$Id: res_mkquery.c,v 1.10 2008/12/11 09:59:00 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@ -123,7 +123,8 @@ res_nmkquery(res_state statp,
return (-1);
memset(buf, 0, HFIXEDSZ);
hp = (HEADER *) buf;
hp->id = htons(++statp->id);
statp->id = res_nrandomid(statp);
hp->id = htons(statp->id);
hp->opcode = op;
hp->rd = (statp->options & RES_RECURSE) != 0U;
hp->rcode = NOERROR;

View File

@ -22,7 +22,7 @@
*/
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: res_mkupdate.c,v 1.4.18.4 2005/10/14 05:44:12 marka Exp $";
static const char rcsid[] = "$Id: res_mkupdate.c,v 1.10 2008/12/11 09:59:00 marka Exp $";
#endif /* not lint */
#include "port_before.h"
@ -101,7 +101,8 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
return (-1);
memset(buf, 0, HFIXEDSZ);
hp = (HEADER *) buf;
hp->id = htons(++statp->id);
statp->id = res_nrandomid(statp);
hp->id = htons(statp->id);
hp->opcode = ns_o_update;
hp->rcode = NOERROR;
cp = buf + HFIXEDSZ;

View File

@ -0,0 +1,25 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1998,1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _RES_MKUPDATE_H_
#define _RES_MKUPDATE_H_
__BEGIN_DECLS
__END_DECLS
#endif /* _RES_MKUPDATE_H_ */
/*! \file */

View File

@ -1,7 +1,24 @@
/*
* Portions Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (C) 1996-2001, 2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -17,7 +34,7 @@
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -33,14 +50,14 @@
/*
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
@ -51,26 +68,9 @@
* SOFTWARE.
*/
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: res_query.c,v 1.7.18.2 2008/04/03 23:15:15 marka Exp $";
static const char rcsid[] = "$Id: res_query.c,v 1.11 2008/11/14 02:36:51 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"

View File

@ -1,7 +1,24 @@
/*
* Portions Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (C) 1996-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Copyright (c) 1985, 1989, 1993
* The Regents of the University of California. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -17,7 +34,7 @@
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -33,14 +50,14 @@
/*
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
*
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
*
*
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
@ -51,26 +68,9 @@
* SOFTWARE.
*/
/*
* Copyright (c) 2005 by Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: res_send.c,v 1.9.18.10 2008/01/27 02:06:26 marka Exp $";
static const char rcsid[] = "$Id: res_send.c,v 1.22 2009/01/22 23:49:23 tbox Exp $";
#endif /* LIBC_SCCS and not lint */
/*! \file
@ -338,7 +338,7 @@ res_nsend(res_state statp,
if (EXT(statp).nssocks[ns] == -1)
continue;
peerlen = sizeof(peer);
if (getsockname(EXT(statp).nssocks[ns],
if (getpeername(EXT(statp).nssocks[ns],
(struct sockaddr *)&peer, &peerlen) < 0) {
needclose++;
break;
@ -389,7 +389,7 @@ res_nsend(res_state statp,
nstime = EXT(statp).nstimes[0];
for (ns = 0; ns < lastns; ns++) {
if (EXT(statp).ext != NULL)
EXT(statp).ext->nsaddrs[ns] =
EXT(statp).ext->nsaddrs[ns] =
EXT(statp).ext->nsaddrs[ns + 1];
statp->nsaddr_list[ns] = statp->nsaddr_list[ns + 1];
EXT(statp).nssocks[ns] = EXT(statp).nssocks[ns + 1];
@ -653,12 +653,12 @@ send_vc(res_state statp,
/*
* Disable generation of SIGPIPE when writing to a closed
* socket. Write should return -1 and set errno to EPIPE
* instead.
* instead.
*
* Push on even if setsockopt(SO_NOSIGPIPE) fails.
*/
(void)setsockopt(statp->_vcsock, SOL_SOCKET, SO_NOSIGPIPE, &on,
sizeof(on));
sizeof(on));
#endif
errno = 0;
if (connect(statp->_vcsock, nsap, nsaplen) < 0) {

View File

@ -0,0 +1,170 @@
#include "port_before.h"
#include "fd_setsize.h"
#include <sys/types.h>
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <isc/dst.h>
#include <errno.h>
#include <netdb.h>
#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "port_after.h"
#define DEBUG
#include "res_debug.h"
/*% res_nsendsigned */
int
res_nsendsigned(res_state statp, const u_char *msg, int msglen,
ns_tsig_key *key, u_char *answer, int anslen)
{
res_state nstatp;
DST_KEY *dstkey;
int usingTCP = 0;
u_char *newmsg;
int newmsglen, bufsize, siglen;
u_char sig[64];
HEADER *hp;
time_t tsig_time;
int ret;
int len;
dst_init();
nstatp = (res_state) malloc(sizeof(*statp));
if (nstatp == NULL) {
errno = ENOMEM;
return (-1);
}
memcpy(nstatp, statp, sizeof(*statp));
bufsize = msglen + 1024;
newmsg = (u_char *) malloc(bufsize);
if (newmsg == NULL) {
free(nstatp);
errno = ENOMEM;
return (-1);
}
memcpy(newmsg, msg, msglen);
newmsglen = msglen;
if (ns_samename(key->alg, NS_TSIG_ALG_HMAC_MD5) != 1)
dstkey = NULL;
else
dstkey = dst_buffer_to_key(key->name, KEY_HMAC_MD5,
NS_KEY_TYPE_AUTH_ONLY,
NS_KEY_PROT_ANY,
key->data, key->len);
if (dstkey == NULL) {
errno = EINVAL;
free(nstatp);
free(newmsg);
return (-1);
}
nstatp->nscount = 1;
siglen = sizeof(sig);
ret = ns_sign(newmsg, &newmsglen, bufsize, NOERROR, dstkey, NULL, 0,
sig, &siglen, 0);
if (ret < 0) {
free (nstatp);
free (newmsg);
dst_free_key(dstkey);
if (ret == NS_TSIG_ERROR_NO_SPACE)
errno = EMSGSIZE;
else if (ret == -1)
errno = EINVAL;
return (ret);
}
if (newmsglen > PACKETSZ || nstatp->options & RES_USEVC)
usingTCP = 1;
if (usingTCP == 0)
nstatp->options |= RES_IGNTC;
else
nstatp->options |= RES_USEVC;
/*
* Stop res_send printing the answer.
*/
nstatp->options &= ~RES_DEBUG;
nstatp->pfcode &= ~RES_PRF_REPLY;
retry:
len = res_nsend(nstatp, newmsg, newmsglen, answer, anslen);
if (len < 0) {
free (nstatp);
free (newmsg);
dst_free_key(dstkey);
return (len);
}
ret = ns_verify(answer, &len, dstkey, sig, siglen,
NULL, NULL, &tsig_time, nstatp->options & RES_KEEPTSIG);
if (ret != 0) {
Dprint((statp->options & RES_DEBUG) ||
((statp->pfcode & RES_PRF_REPLY) &&
(statp->pfcode & RES_PRF_HEAD1)),
(stdout, ";; got answer:\n"));
DprintQ((statp->options & RES_DEBUG) ||
(statp->pfcode & RES_PRF_REPLY),
(stdout, "%s", ""),
answer, (anslen > len) ? len : anslen);
if (ret > 0) {
Dprint(statp->pfcode & RES_PRF_REPLY,
(stdout, ";; server rejected TSIG (%s)\n",
p_rcode(ret)));
} else {
Dprint(statp->pfcode & RES_PRF_REPLY,
(stdout, ";; TSIG invalid (%s)\n",
p_rcode(-ret)));
}
free (nstatp);
free (newmsg);
dst_free_key(dstkey);
if (ret == -1)
errno = EINVAL;
else
errno = ENOTTY;
return (-1);
}
hp = (HEADER *) answer;
if (hp->tc && !usingTCP && (statp->options & RES_IGNTC) == 0U) {
nstatp->options &= ~RES_IGNTC;
usingTCP = 1;
goto retry;
}
Dprint((statp->options & RES_DEBUG) ||
((statp->pfcode & RES_PRF_REPLY) &&
(statp->pfcode & RES_PRF_HEAD1)),
(stdout, ";; got answer:\n"));
DprintQ((statp->options & RES_DEBUG) ||
(statp->pfcode & RES_PRF_REPLY),
(stdout, "%s", ""),
answer, (anslen > len) ? len : anslen);
Dprint(statp->pfcode & RES_PRF_REPLY, (stdout, ";; TSIG ok\n"));
free (nstatp);
free (newmsg);
dst_free_key(dstkey);
return (len);
}
/*! \file */

View File

@ -1,5 +1,5 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: res_update.c,v 1.12.18.1 2005/04/27 05:01:12 sra Exp $";
static const char rcsid[] = "$Id: res_update.c,v 1.13 2005/04/27 04:56:43 sra Exp $";
#endif /* not lint */
/*