* Ported libbind-6.0 to Haiku, and into our libnetwork.so.

* Got rid of the TLS/multi-thread hacks of the previous port.
* Took over irs/lcl_sv.cpp, and irs/lcl_ho.c, and irs/lcl_pr.c from the previous
  version as they contain customizations.
* Removed unused files from libbind.
* Only barely tested, so beware.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33968 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-11-09 22:18:34 +00:00
parent ecf6b86c92
commit 4bd3cce627
197 changed files with 16648 additions and 3224 deletions

View File

@ -6,7 +6,7 @@
/*
* Copyright (c) 1983, 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:
@ -22,7 +22,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
@ -36,14 +36,14 @@
* SUCH DAMAGE.
* -
* 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
@ -97,7 +97,8 @@ char *inet_cidr_ntop(int, const void *, int, char *, size_t);
int inet_cidr_pton(int, const char *, void *, int *);
char *inet_ntoa(struct in_addr);
int inet_pton(int, const char *, void *);
const char *inet_ntop(int, const void *, char *, socklen_t);
const char* inet_ntop(int family, const void* source, char* dest,
socklen_t size);
u_int inet_nsap_addr(const char *, u_char *, int);
char *inet_nsap_ntoa(int, const u_char *, char *);

View File

@ -1,12 +1,29 @@
/*
* Copyright 2006, Haiku, Inc. All Rights Reserved.
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
/*
* 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:
@ -22,7 +39,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
@ -35,23 +52,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* 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.
*/
#ifndef _ARPA_NAMESER_H_
#define _ARPA_NAMESER_H_
@ -69,7 +69,7 @@
* compare for equality; rather, use it to determine whether your libbind.a
* 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 RFC 883, RFC 1034, RFC 1035
@ -79,6 +79,9 @@
#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 40
#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 */
@ -105,6 +108,18 @@ typedef enum __ns_sect {
ns_s_max = 4
} ns_sect;
/*
* Network name (compressed or not) type. Equivalent 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
@ -122,6 +137,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[];
@ -146,8 +172,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)
@ -296,6 +337,17 @@ typedef enum __ns_type {
ns_t_sink = 40, /* Kitchen sink (experimentatl) */
ns_t_opt = 41, /* EDNS0 option (meta-RR) */
ns_t_apl = 42, /* Address prefix list (RFC 3123) */
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;
@ -373,13 +426,9 @@ typedef enum __ns_cert_types {
#define NS_KEY_RESERVED10 0x0020 /* reserved - must be zero */
#define NS_KEY_RESERVED11 0x0010 /* reserved - must be zero */
#define NS_KEY_SIGNATORYMASK 0x000F /* key can sign RR's of same name */
#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \
NS_KEY_RESERVED4 | \
NS_KEY_RESERVED5 | \
NS_KEY_RESERVED8 | \
NS_KEY_RESERVED9 | \
NS_KEY_RESERVED10 | \
NS_KEY_RESERVED11 )
#define NS_KEY_RESERVED_BITMASK (NS_KEY_RESERVED2 | NS_KEY_RESERVED4 \
| NS_KEY_RESERVED5 | NS_KEY_RESERVED8 | NS_KEY_RESERVED9 \
| NS_KEY_RESERVED10 | NS_KEY_RESERVED11)
#define NS_KEY_RESERVED_BITMASK2 0xFFFF /* no bits defined here */
/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */
@ -433,6 +482,7 @@ typedef enum __ns_cert_types {
* EDNS0 extended flags, host order.
*/
#define NS_OPT_DNSSEC_OK 0x8000U
#define NS_OPT_NSID 3
/*
* Inline versions of get/put short/long. Pointer is advanced.
@ -484,6 +534,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
@ -492,12 +543,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
@ -511,6 +569,17 @@ 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
#ifdef __cplusplus
extern "C" {
@ -524,6 +593,7 @@ void ns_put32(u_long, u_char *);
int ns_initparse(const u_char *, int, ns_msg *);
int ns_skiprr(const u_char *, const u_char *, ns_sect, int);
int ns_parserr(ns_msg *, ns_sect, int, ns_rr *);
int ns_parserr2(ns_msg *, ns_sect, int, ns_rr2 *);
int ns_sprintrr(const ns_msg *, const ns_rr *,
const char *, const char *, char *, size_t);
int ns_sprintrrf(const u_char *, size_t, const char *,
@ -536,8 +606,11 @@ u_int32_t ns_datetosecs(const char *cp, int *errp);
int ns_name_ntol(const u_char *, u_char *, size_t);
int ns_name_ntop(const u_char *, char *, size_t);
int ns_name_pton(const char *, u_char *, size_t);
int ns_name_pton2(const char *, u_char *, size_t, size_t *);
int ns_name_unpack(const u_char *, const u_char *,
const u_char *, u_char *, size_t);
int ns_name_unpack2(const u_char *, const u_char *,
const u_char *, u_char *, size_t, size_t *);
int ns_name_pack(const u_char *, u_char *, int,
const u_char **, const u_char **);
int ns_name_uncompress(const u_char *, const u_char *,
@ -545,8 +618,15 @@ int ns_name_uncompress(const u_char *, const u_char *,
int ns_name_compress(const char *, u_char *, size_t,
const u_char **, const u_char **);
int ns_name_skip(const u_char **, const u_char *);
void ns_name_rollback(const u_char *, const u_char **,
const u_char **);
void ns_name_rollback(const u_char *, const u_char **, const u_char **);
ssize_t ns_name_length(ns_nname_ct nname, size_t nameSize);
int ns_name_eq(ns_nname_ct a, size_t aLength, ns_nname_ct b,
size_t bLength);
int ns_name_owned(ns_namemap_ct a, int aLength, ns_namemap_ct b,
int bLength);
int ns_name_map(ns_nname_ct nname, size_t nameLength, ns_namemap_t map,
int mapSize);
int ns_name_labels(ns_nname_ct, size_t);
int ns_sign(u_char *, int *, int, int, void *,
const u_char *, int, u_char *, int *, time_t);
int ns_sign2(u_char *, int *, int, int, void *,
@ -570,6 +650,20 @@ int ns_samedomain(const char *, const char *);
int ns_subdomain(const char *, const char *);
int ns_makecanon(const char *, char *, size_t);
int ns_samename(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 *);
#ifdef __cplusplus
}

View File

@ -27,4 +27,15 @@ struct sockaddr_in6 {
uint32_t sin6_scope_id;
};
#define IN6ADDR_ANY_INIT \
{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
#define IN6ADDR_LOOPBACK_INIT \
{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
extern const struct in6_addr in6addr_any;
extern const struct in6_addr in6addr_loopback;
#endif /* _NETINET6_IN6_H_ */

View File

@ -1,7 +1,29 @@
/*
* Copyright 2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
/*
* 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 +39,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,39 +53,26 @@
* 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 18456 2006-08-08 12:33:33Z axeld $
* $Id: resolv.h,v 1.30 2009/03/03 01:52:48 each Exp $
*/
#ifndef _RESOLV_H_
#define _RESOLV_H_
#include <sys/param.h>
#include <sys/types.h>
#if (!defined(BSD)) || (BSD < 199306)
# include <sys/bitypes.h>
#else
# include <sys/types.h>
#endif
#include <sys/cdefs.h>
#include <sys/socket.h>
#include <stdio.h>
#include <arpa/nameser.h>
/*
/*%
* Revision information. This is the release date in YYYYMMDD format.
* It can change every day so the right thing to do with it is use it
* in preprocessor commands such as "#if (__RES > 19931104)". Do not
@ -71,9 +80,9 @@
* 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.
* [XXX no it's not. It's in irs/irs_data.c]
* It was
@ -93,12 +102,12 @@
*/
#define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x)
struct __res_state; /* forward */
struct __res_state; /*%< forward */
__BEGIN_DECLS
void __h_errno_set(struct __res_state *res, int err);
__END_DECLS
/*
/*%
* Resolver configuration file.
* Normally not present, but may contain the address of the
* initial name server(s) to query and the domain search list.
@ -119,71 +128,76 @@ typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
#endif
#endif
typedef res_sendhookact (*res_send_qhook)__PMT((struct sockaddr * const *,
const u_char **, int *,
u_char *, int, int *));
typedef res_sendhookact (*res_send_qhook)(struct sockaddr * const *,
const u_char **, int *, u_char *, int, int *);
typedef res_sendhookact (*res_send_rhook)__PMT((const struct sockaddr *,
const u_char *, int, u_char *,
int, int *));
typedef res_sendhookact (*res_send_rhook)(const struct sockaddr *,
const u_char *, int, u_char *, int, int *);
struct res_sym {
int number; /* Identifying number, like T_MX */
const char * name; /* Its symbolic name, like "MX" */
const char * humanname; /* Its fun name, like "mail exchanger" */
int number; /*%< Identifying number, like T_MX */
const char * name; /*%< Its symbolic name, like "MX" */
const char * humanname; /*%< Its fun name, like "mail exchanger" */
};
/*
/*%
* Global defines and variables for resolver stub.
*/
#define MAXNS 3 /* max # name servers we'll track */
#define MAXDFLSRCH 3 /* # default domain levels to try */
#define MAXDNSRCH 6 /* max # domains in search path */
#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
#define RES_TIMEOUT 5 /* min. seconds between retries */
#define MAXRESOLVSORT 10 /* number of net to sort on */
#define RES_MAXNDOTS 15 /* should reflect bit field size */
#define RES_MAXRETRANS 30 /* only for resolv.conf/RES_OPTIONS */
#define RES_MAXRETRY 5 /* only for resolv.conf/RES_OPTIONS */
#define RES_DFLRETRY 2 /* Default #/tries. */
#define RES_MAXTIME 65535 /* Infinity, in milliseconds. */
#define MAXNS 3 /*%< max # name servers we'll track */
#define MAXDFLSRCH 3 /*%< # default domain levels to try */
#define MAXDNSRCH 6 /*%< max # domains in search path */
#define LOCALDOMAINPARTS 2 /*%< min levels in name that is "local" */
#define RES_TIMEOUT 5 /*%< min. seconds between retries */
#define MAXRESOLVSORT 10 /*%< number of net to sort on */
#define RES_MAXNDOTS 15 /*%< should reflect bit field size */
#define RES_MAXRETRANS 30 /*%< only for resolv.conf/RES_OPTIONS */
#define RES_MAXRETRY 5 /*%< only for resolv.conf/RES_OPTIONS */
#define RES_DFLRETRY 2 /*%< Default #/tries. */
#define RES_MAXTIME 65535 /*%< Infinity, in milliseconds. */
struct __res_state_ext;
struct __res_state {
int retrans; /* retransmission time interval */
int retry; /* number of times to retransmit */
u_long options; /* option flags - see below. */
int nscount; /* number of name servers */
int retrans; /*%< retransmission time interval */
int retry; /*%< number of times to retransmit */
#ifdef sun
u_int options; /*%< option flags - see below. */
#else
u_long options; /*%< option flags - see below. */
#endif
int nscount; /*%< number of name servers */
struct sockaddr_in
nsaddr_list[MAXNS]; /* address of name server */
#define nsaddr nsaddr_list[0] /* for backward compatibility */
u_short id; /* current message id */
char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
char defdname[256]; /* default domain (deprecated) */
u_long pfcode; /* RES_PRF_ flags - see below. */
unsigned ndots:4; /* threshold for initial abs. query */
unsigned nsort:4; /* number of elements in sort_list[] */
nsaddr_list[MAXNS]; /*%< address of name server */
#define nsaddr nsaddr_list[0] /*%< for backward compatibility */
u_short id; /*%< current message id */
char *dnsrch[MAXDNSRCH+1]; /*%< components of domain to search */
char defdname[256]; /*%< default domain (deprecated) */
#ifdef sun
u_int pfcode; /*%< RES_PRF_ flags - see below. */
#else
u_long pfcode; /*%< RES_PRF_ flags - see below. */
#endif
unsigned ndots:4; /*%< threshold for initial abs. query */
unsigned nsort:4; /*%< number of elements in sort_list[] */
char unused[3];
struct {
struct in_addr addr;
u_int32_t mask;
} sort_list[MAXRESOLVSORT];
res_send_qhook qhook; /* query hook */
res_send_rhook rhook; /* response hook */
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_int _pad; /* make _u 64 bit aligned */
res_send_qhook qhook; /*%< query hook */
res_send_rhook rhook; /*%< response hook */
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. */
u_int16_t nstimes[MAXNS]; /*%< ms. */
int nssocks[MAXNS];
struct __res_state_ext *ext; /* extention for IPv6 */
struct __res_state_ext *ext; /*%< extention for IPv6 */
} _ext;
} _u;
};
@ -192,76 +206,75 @@ typedef struct __res_state *res_state;
union res_sockaddr_union {
struct sockaddr_in sin;
#ifdef IN6ADDR_ANY_INIT
struct sockaddr_in6 sin6;
#endif
#ifdef ISC_ALIGN64
int64_t __align64; /* 64bit alignment */
int64_t __align64; /*%< 64bit alignment */
#else
int32_t __align32; /* 32bit alignment */
int32_t __align32; /*%< 32bit alignment */
#endif
char __space[128]; /* max size */
char __space[128]; /*%< max size */
};
/*
/*%
* Resolver flags (used to be discrete per-module statics ints).
*/
#define RES_F_VC 0x00000001 /* socket is TCP */
#define RES_F_CONN 0x00000002 /* socket is connected */
#define RES_F_EDNS0ERR 0x00000004 /* EDNS0 caused errors */
#define RES_F__UNUSED 0x00000008 /* (unused) */
#define RES_F_LASTMASK 0x000000F0 /* ordinal server of last res_nsend */
#define RES_F_LASTSHIFT 4 /* bit position of LASTMASK "flag" */
#define RES_F_VC 0x00000001 /*%< socket is TCP */
#define RES_F_CONN 0x00000002 /*%< socket is connected */
#define RES_F_EDNS0ERR 0x00000004 /*%< EDNS0 caused errors */
#define RES_F__UNUSED 0x00000008 /*%< (unused) */
#define RES_F_LASTMASK 0x000000F0 /*%< ordinal server of last res_nsend */
#define RES_F_LASTSHIFT 4 /*%< bit position of LASTMASK "flag" */
#define RES_GETLAST(res) (((res)._flags & RES_F_LASTMASK) >> RES_F_LASTSHIFT)
/* res_findzonecut2() options */
#define RES_EXHAUSTIVE 0x00000001 /* always do all queries */
#define RES_IPV4ONLY 0x00000002 /* IPv4 only */
#define RES_IPV6ONLY 0x00000004 /* IPv6 only */
#define RES_EXHAUSTIVE 0x00000001 /*%< always do all queries */
#define RES_IPV4ONLY 0x00000002 /*%< IPv4 only */
#define RES_IPV6ONLY 0x00000004 /*%< IPv6 only */
/*
/*%
* Resolver options (keep these in synch with res_debug.c, please)
*/
#define RES_INIT 0x00000001 /* address initialized */
#define RES_DEBUG 0x00000002 /* print debug messages */
#define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/
#define RES_USEVC 0x00000008 /* use virtual circuit */
#define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */
#define RES_IGNTC 0x00000020 /* ignore trucation errors */
#define RES_RECURSE 0x00000040 /* recursion desired */
#define RES_DEFNAMES 0x00000080 /* use default domain name */
#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */
#define RES_DNSRCH 0x00000200 /* search up local domain tree */
#define RES_INSECURE1 0x00000400 /* type 1 security disabled */
#define RES_INSECURE2 0x00000800 /* type 2 security disabled */
#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
#define RES_USE_INET6 0x00002000 /* use/map IPv6 in gethostbyname() */
#define RES_ROTATE 0x00004000 /* rotate ns list after each query */
#define RES_NOCHECKNAME 0x00008000 /* do not check names for sanity. */
#define RES_KEEPTSIG 0x00010000 /* do not strip TSIG records */
#define RES_BLAST 0x00020000 /* blast all recursive servers */
#define RES_NOTLDQUERY 0x00100000 /* don't unqualified name as a tld */
#define RES_USE_DNSSEC 0x00200000 /* use DNSSEC using OK bit in OPT */
#define RES_INIT 0x00000001 /*%< address initialized */
#define RES_DEBUG 0x00000002 /*%< print debug messages */
#define RES_AAONLY 0x00000004 /*%< authoritative answers only (!IMPL)*/
#define RES_USEVC 0x00000008 /*%< use virtual circuit */
#define RES_PRIMARY 0x00000010 /*%< query primary server only (!IMPL) */
#define RES_IGNTC 0x00000020 /*%< ignore trucation errors */
#define RES_RECURSE 0x00000040 /*%< recursion desired */
#define RES_DEFNAMES 0x00000080 /*%< use default domain name */
#define RES_STAYOPEN 0x00000100 /*%< Keep TCP socket open */
#define RES_DNSRCH 0x00000200 /*%< search up local domain tree */
#define RES_INSECURE1 0x00000400 /*%< type 1 security disabled */
#define RES_INSECURE2 0x00000800 /*%< type 2 security disabled */
#define RES_NOALIASES 0x00001000 /*%< shuts off HOSTALIASES feature */
#define RES_USE_INET6 0x00002000 /*%< use/map IPv6 in gethostbyname() */
#define RES_ROTATE 0x00004000 /*%< rotate ns list after each query */
#define RES_NOCHECKNAME 0x00008000 /*%< do not check names for sanity. */
#define RES_KEEPTSIG 0x00010000 /*%< do not strip TSIG records */
#define RES_BLAST 0x00020000 /*%< blast all recursive servers */
#define RES_NSID 0x00040000 /*%< request name server ID */
#define RES_NOTLDQUERY 0x00100000 /*%< don't unqualified name as a tld */
#define RES_USE_DNSSEC 0x00200000 /*%< use DNSSEC using OK bit in OPT */
/* #define RES_DEBUG2 0x00400000 */ /* nslookup internal */
/* KAME extensions: use higher bit to avoid conflict with ISC use */
#define RES_USE_DNAME 0x10000000 /* use DNAME */
#define RES_USE_EDNS0 0x40000000 /* use EDNS0 if configured */
#define RES_NO_NIBBLE2 0x80000000 /* disable alternate nibble lookup */
#define RES_USE_DNAME 0x10000000 /*%< use DNAME */
#define RES_USE_EDNS0 0x40000000 /*%< use EDNS0 if configured */
#define RES_NO_NIBBLE2 0x80000000 /*%< disable alternate nibble lookup */
#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | \
RES_DNSRCH | RES_NO_NIBBLE2)
/*
/*%
* Resolver "pfcode" values. Used by dig.
*/
#define RES_PRF_STATS 0x00000001
#define RES_PRF_UPDATE 0x00000002
#define RES_PRF_CLASS 0x00000004
#define RES_PRF_CMD 0x00000008
#define RES_PRF_CMD 0x00000008
#define RES_PRF_QUES 0x00000010
#define RES_PRF_ANS 0x00000020
#define RES_PRF_ANS 0x00000020
#define RES_PRF_AUTH 0x00000040
#define RES_PRF_ADD 0x00000080
#define RES_PRF_ADD 0x00000080
#define RES_PRF_HEAD1 0x00000100
#define RES_PRF_HEAD2 0x00000200
#define RES_PRF_TTLID 0x00000400
@ -285,37 +298,38 @@ __END_DECLS
#define p_query __p_query
#define res_close __res_close
#define res_init __res_init
#define res_isourserver __res_isourserver
#define res_isourserver __res_isourserver
#define res_mkquery __res_mkquery
#define res_query __res_query
#define res_querydomain __res_querydomain
#define res_querydomain __res_querydomain
#define res_search __res_search
#define res_send __res_send
#define res_sendsigned __res_sendsigned
#define res_sendsigned __res_sendsigned
__BEGIN_DECLS
void fp_nquery __P((const u_char *, int, FILE *));
void fp_query __P((const u_char *, FILE *));
const char * hostalias __P((const char *));
void p_query __P((const u_char *));
void res_close __P((void));
int res_init __P((void));
int res_isourserver __P((const struct sockaddr_in *));
int res_mkquery __P((int, const char *, int, int, const u_char *,
int, const u_char *, u_char *, int));
int res_query __P((const char *, int, int, u_char *, int));
int res_querydomain __P((const char *, const char *, int, int,
u_char *, int));
int res_search __P((const char *, int, int, u_char *, int));
int res_send __P((const u_char *, int, u_char *, int));
int res_sendsigned __P((const u_char *, int, ns_tsig_key *,
u_char *, int));
void fp_nquery(const u_char *, int, FILE *);
void fp_query(const u_char *, FILE *);
const char *hostalias(const char *);
void p_query(const u_char *);
void res_close(void);
int res_init(void);
int res_isourserver(const struct sockaddr_in *);
int res_mkquery(int, const char *, int, int, const u_char *,
int, const u_char *, u_char *, int);
int res_query(const char *, int, int, u_char *, int);
int res_querydomain(const char *, const char *, int, int,
u_char *, int);
int res_search(const char *, int, int, u_char *, int);
int res_send(const u_char *, int, u_char *, int);
int res_sendsigned(const u_char *, int, ns_tsig_key *,
u_char *, int);
__END_DECLS
#endif
#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
*
@ -325,54 +339,58 @@ extern const struct res_sym __p_cert_syms[];
extern const struct res_sym __p_class_syms[];
extern const struct res_sym __p_type_syms[];
extern const struct res_sym __p_rcode_syms[];
#endif /* SHARED_LIBBIND */
#define b64_ntop __b64_ntop
#define b64_pton __b64_pton
#define dn_comp __dn_comp
#define b64_ntop __b64_ntop
#define b64_pton __b64_pton
#define dn_comp __dn_comp
#define dn_count_labels __dn_count_labels
#define dn_expand __dn_expand
#define dn_skipname __dn_skipname
#define fp_resstat __fp_resstat
#define loc_aton __loc_aton
#define loc_ntoa __loc_ntoa
#define p_cdname __p_cdname
#define p_cdnname __p_cdnname
#define p_class __p_class
#define p_fqname __p_fqname
#define p_fqnname __p_fqnname
#define p_option __p_option
#define dn_expand __dn_expand
#define dn_skipname __dn_skipname
#define fp_resstat __fp_resstat
#define loc_aton __loc_aton
#define loc_ntoa __loc_ntoa
#define p_cdname __p_cdname
#define p_cdnname __p_cdnname
#define p_class __p_class
#define p_fqname __p_fqname
#define p_fqnname __p_fqnname
#define p_option __p_option
#define p_secstodate __p_secstodate
#define p_section __p_section
#define p_time __p_time
#define p_type __p_type
#define p_rcode __p_rcode
#define p_sockun __p_sockun
#define putlong __putlong
#define putshort __putshort
#define res_dnok __res_dnok
#define p_section __p_section
#define p_time __p_time
#define p_type __p_type
#define p_rcode __p_rcode
#define p_sockun __p_sockun
#define putlong __putlong
#define putshort __putshort
#define res_dnok __res_dnok
#define res_findzonecut __res_findzonecut
#define res_findzonecut2 __res_findzonecut2
#define res_hnok __res_hnok
#define res_hnok __res_hnok
#define res_hostalias __res_hostalias
#define res_mailok __res_mailok
#define res_mailok __res_mailok
#define res_nameinquery __res_nameinquery
#define res_nclose __res_nclose
#define res_ninit __res_ninit
#define res_nclose __res_nclose
#define res_ninit __res_ninit
#define res_nmkquery __res_nmkquery
#define res_pquery __res_pquery
#define res_nquery __res_nquery
#define res_pquery __res_pquery
#define res_nquery __res_nquery
#define res_nquerydomain __res_nquerydomain
#define res_nsearch __res_nsearch
#define res_nsend __res_nsend
#define res_nsearch __res_nsearch
#define res_nsend __res_nsend
#define res_nsendsigned __res_nsendsigned
#define res_nisourserver __res_nisourserver
#define res_ownok __res_ownok
#define res_ownok __res_ownok
#define res_queriesmatch __res_queriesmatch
#define res_rndinit __res_rndinit
#define res_randomid __res_randomid
#define sym_ntop __sym_ntop
#define sym_ntos __sym_ntos
#define sym_ston __sym_ston
#define res_nopt __res_nopt
#define res_nrandomid __res_nrandomid
#define sym_ntop __sym_ntop
#define sym_ntos __sym_ntos
#define sym_ston __sym_ston
#define res_nopt __res_nopt
#define res_nopt_rdata __res_nopt_rdata
#define res_ndestroy __res_ndestroy
#define res_nametoclass __res_nametoclass
#define res_nametotype __res_nametotype
@ -390,88 +408,88 @@ extern const struct res_sym __p_rcode_syms[];
#define res_send_setrhook __res_send_setrhook
#define res_servicename __res_servicename
#define res_servicenumber __res_servicenumber
__BEGIN_DECLS
int res_hnok __P((const char *));
int res_ownok __P((const char *));
int res_mailok __P((const char *));
int res_dnok __P((const char *));
int sym_ston __P((const struct res_sym *, const char *, int *));
const char * sym_ntos __P((const struct res_sym *, int, int *));
const char * sym_ntop __P((const struct res_sym *, int, int *));
int b64_ntop __P((u_char const *, size_t, char *, size_t));
int b64_pton __P((char const *, u_char *, size_t));
int loc_aton __P((const char *, u_char *));
const char * loc_ntoa __P((const u_char *, char *));
int dn_skipname __P((const u_char *, const u_char *));
void putlong __P((u_int32_t, u_char *));
void putshort __P((u_int16_t, u_char *));
const char * p_class __P((int));
const char * p_time __P((u_int32_t));
const char * p_type __P((int));
const char * p_rcode __P((int));
const char * p_sockun __P((union res_sockaddr_union, char *, size_t));
const u_char * p_cdnname __P((const u_char *, const u_char *, int, FILE *));
const u_char * p_cdname __P((const u_char *, const u_char *, FILE *));
const u_char * p_fqnname __P((const u_char *, const u_char *,
int, char *, int));
const u_char * p_fqname __P((const u_char *, const u_char *, FILE *));
const char * p_option __P((u_long));
char * p_secstodate __P((u_long));
int dn_count_labels __P((const char *));
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));
u_int res_randomid __P((void));
int res_nameinquery __P((const char *, int, int, const u_char *,
const u_char *));
int res_queriesmatch __P((const u_char *, const u_char *,
const u_char *, const u_char *));
const char * p_section __P((int, int));
int res_hnok(const char *);
int res_ownok(const char *);
int res_mailok(const char *);
int res_dnok(const char *);
int sym_ston(const struct res_sym *, const char *, int *);
const char * sym_ntos(const struct res_sym *, int, int *);
const char * sym_ntop(const struct res_sym *, int, int *);
int b64_ntop(u_char const *, size_t, char *, size_t);
int b64_pton(char const *, u_char *, size_t);
int loc_aton(const char *, u_char *);
const char * loc_ntoa(const u_char *, char *);
int dn_skipname(const u_char *, const u_char *);
void putlong(u_int32_t, u_char *);
void putshort(u_int16_t, u_char *);
#ifndef __ultrix__
u_int16_t _getshort(const u_char *);
u_int32_t _getlong(const u_char *);
#endif
const char * p_class(int);
const char * p_time(u_int32_t);
const char * p_type(int);
const char * p_rcode(int);
const char * p_sockun(union res_sockaddr_union, char *, size_t);
const u_char * p_cdnname(const u_char *, const u_char *, int, FILE *);
const u_char * p_cdname(const u_char *, const u_char *, FILE *);
const u_char * p_fqnname(const u_char *, const u_char *, int, char *, int);
const u_char * p_fqname(const u_char *, const u_char *, FILE *);
const char * p_option(u_long);
char * p_secstodate(u_long);
int dn_count_labels(const char *);
int dn_comp(const char *, u_char *, int, u_char **, u_char **);
int dn_expand(const u_char *, const u_char *, const u_char *,
char *, int);
void res_rndinit(res_state);
u_int res_randomid(void);
u_int res_nrandomid(res_state);
int res_nameinquery(const char *, int, int, const u_char *,
const u_char *);
int res_queriesmatch(const u_char *, const u_char *, const u_char *,
const u_char *);
const char * p_section(int, int);
/* Things involving a resolver context. */
int res_ninit __P((res_state));
int res_nisourserver __P((const res_state,
const struct sockaddr_in *));
void fp_resstat __P((const res_state, FILE *));
void res_pquery __P((const res_state, const u_char *, int, FILE *));
const char * res_hostalias __P((const res_state, const char *,
char *, size_t));
int res_nquery __P((res_state, const char *, int, int,
u_char *, int));
int res_nsearch __P((res_state, const char *, int, int, u_char *,
int));
int res_nquerydomain __P((res_state, const char *, const char *,
int, int, u_char *, int));
int res_nmkquery __P((res_state, int, const char *, int, int,
const u_char *, int, const u_char *,
u_char *, int));
int res_nsend __P((res_state, const u_char *, int, u_char *, int));
int res_nsendsigned __P((res_state, const u_char *, int,
ns_tsig_key *, u_char *, int));
int res_findzonecut __P((res_state, const char *, ns_class, int,
char *, size_t, struct in_addr *, int));
int res_findzonecut2 __P((res_state, const char *, ns_class, int,
char *, size_t,
union res_sockaddr_union *, int));
void res_nclose __P((res_state));
int res_nopt __P((res_state, int, u_char *, int, int));
void res_send_setqhook __P((res_send_qhook));
void res_send_setrhook __P((res_send_rhook));
int __res_vinit __P((res_state, int));
void res_destroyservicelist __P((void));
const char * res_servicename __P((u_int16_t, const char *));
const char * res_protocolname __P((int));
void res_destroyprotolist __P((void));
void res_buildprotolist __P((void));
const char * res_get_nibblesuffix __P((res_state));
const char * res_get_nibblesuffix2 __P((res_state));
void res_ndestroy __P((res_state));
u_int16_t res_nametoclass __P((const char *, int *));
u_int16_t res_nametotype __P((const char *, int *));
void res_setservers __P((res_state,
const union res_sockaddr_union *, int));
int res_getservers __P((res_state,
union res_sockaddr_union *, int));
int res_ninit(res_state);
int res_nisourserver(const res_state, const struct sockaddr_in *);
void fp_resstat(const res_state, FILE *);
void res_pquery(const res_state, const u_char *, int, FILE *);
const char * res_hostalias(const res_state, const char *, char *, size_t);
int res_nquery(res_state, const char *, int, int, u_char *, int);
int res_nsearch(res_state, const char *, int, int, u_char *, int);
int res_nquerydomain(res_state, const char *, const char *, int,
int, u_char *, int);
int res_nmkquery(res_state, int, const char *, int, int,
const u_char *, int, const u_char *, u_char *, int);
int res_nsend(res_state, const u_char *, int, u_char *, int);
int res_nsendsigned(res_state, const u_char *, int, ns_tsig_key *,
u_char *, int);
int res_findzonecut(res_state, const char *, ns_class, int, char *,
size_t, struct in_addr *, int);
int res_findzonecut2(res_state, const char *, ns_class, int, char *,
size_t, union res_sockaddr_union *, int);
void res_nclose(res_state);
int res_nopt(res_state, int, u_char *, int, int);
int res_nopt_rdata(res_state, int, u_char *, int, u_char *, u_short,
u_short, u_char *);
void res_send_setqhook(res_send_qhook);
void res_send_setrhook(res_send_rhook);
int __res_vinit(res_state, int);
void res_destroyservicelist(void);
const char * res_servicename(u_int16_t, const char *);
const char * res_protocolname(int);
void res_destroyprotolist(void);
void res_buildprotolist(void);
const char * res_get_nibblesuffix(res_state);
const char * res_get_nibblesuffix2(res_state);
void res_ndestroy(res_state);
u_int16_t res_nametoclass(const char *, int *);
u_int16_t res_nametotype(const char *, int *);
void res_setservers(res_state, const union res_sockaddr_union *,
int);
int res_getservers(res_state, union res_sockaddr_union *, int);
__END_DECLS
#endif /* !_RESOLV_H_ */

View File

@ -11,19 +11,19 @@ SharedLibrary libnetwork.so :
r5_compatibility.cpp
:
be
<libnetwork_dns>dns_dst.o
<libnetwork_dns>dns_inet.o
<libnetwork_dns>dns_irs.o
<libnetwork_dns>dns_isc.o
<libnetwork_dns>dns_nameser.o
<libnetwork_dns>dns_resolv.o
<libnetwork_dns>dns_private.o
<libbind>libbind_dst.o
<libbind>libbind_inet.o
<libbind>libbind_irs.o
<libbind>libbind_isc.o
<libbind>libbind_nameser.o
<libbind>libbind_resolv.o
<libbind>libbind_private.o
$(TARGET_LIBSUPC++)
;
local services = [ FGristFiles services ] ;
SEARCH on $(services) = [ FDirName $(SUBDIR) dns defaults ] ;
SEARCH on $(services) = [ FDirName $(SUBDIR) libbind defaults ] ;
AddFileDataAttribute libnetwork.so : services : string : $(services) ;
SubInclude HAIKU_TOP src kits network dns ;
SubInclude HAIKU_TOP src kits network libbind ;
SubInclude HAIKU_TOP src kits network libnetapi ;

View File

@ -1,53 +0,0 @@
BIND 9.3.1
ported to Haiku
This file contains important information for developers who want to update this BIND port.
I created config.h, port_before.h, and port_after.h with "configure --enable-threads --disable-ipv6" on a BONE-compatible system and fixed some mistakes that the script made. All changes to these three files are marked with a comment containing the keyword CHANGED.
TODO:
add support for IPv6
improve pthread support to fix TLS/mutex hack
Added folders and files:
headers (some headers are not defined in Haiku)
src (functions that are not part of Haiku, e.g.: strsep)
All BIND headers were moved to legacy/network (public) and private/net (private) in the system-wide headers folder.
Removed files:
irs/
dns_gr.c
dns_pw.c
gen_gr.c
gen_pw.c
getgrent.c
getgrent_r.c
getpwent.c
getpwent_r.c
irp_gr.c
irp_pw.c
lcl_gr.c
lcl_pw.c
nis_gr.c
nis_ho.c
nis_ng.c
nis_nw.c
nis_pr.c
nis_pw.c
nis_sv.c
Porting issues:
BIND wants to include sys/un.h and utmp.h. We do not have these, so I put empty headers into the private headers folder.
Added a hacky workaround when building for non-Haiku targets: select.h (in legacy headers) only declares pselect() for Haiku.
Added sources for compatibility:
src/res_resultcodes.c: BONE's host command wants _res_resultcodes to be defined
Changes made to the sources and headers:
nameser_compat.h: added check for __HAIKU__ and __BEOS__ to not redefine endianness
arpa/inet.h, netdb.h, resolv.h, nameser.h, nameser_compat.h: removed check for _REENTRANT (we are always reentrant), removed all checks for other operating systems
irs/gai_strerror.c, irs/irs_data.c: Switched to BeOS-native TLS in gai_strerror() and net_data_init() using a very ugly hack (see src/TLSInit.cpp). We need full mutex support!

View File

@ -1,39 +0,0 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-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: misc.h 15585 2005-12-19 13:26:54Z wkornew $
*/
#ifndef _ISC_MISC_H
#define _ISC_MISC_H
#include <stdio.h>
#define bitncmp __bitncmp
/*#define isc_movefile __isc_movefile */
extern int bitncmp(const void *, const void *, int);
extern int isc_movefile(const char *, const char *);
extern int isc_gethexstring(unsigned char *, size_t, int, FILE *,
int *);
extern void isc_puthexstring(FILE *, const unsigned char *, size_t,
size_t, size_t, const char *);
extern void isc_tohex(const unsigned char *, size_t, char *);
#endif /*_ISC_MISC_H*/

View File

@ -1,27 +0,0 @@
#ifndef PTHREAD_EMU_H
#define PTHREAD_EMU_H
#ifdef __cplusplus
extern "C" {
#endif
#include <TLS.h>
#include <pthread.h>
#include <OS.h>
typedef int32 pthread_key_t;
extern pthread_mutex_t pthread_mutex_static_initializer(void);
extern int pthread_key_create(pthread_key_t *key, void (*destructor)(void *));
extern int pthread_setspecific(pthread_key_t key, void *value);
extern void *pthread_getspecific(pthread_key_t key);
#ifdef __cplusplus
}
#endif
#endif /* PTHREAD_EMU_H */

View File

@ -1,8 +0,0 @@
#ifndef _SYS_UN_H
#define _SYS_UN_H
/* TODO: implement */
#endif /* _SYS_UN_H */

View File

@ -1,8 +0,0 @@
#ifndef UTMP_H
#define UTMP_H
/* TODO: implement */
#endif /* UTMP_H */

View File

@ -1,20 +0,0 @@
#include <TLS.h>
#include <OS.h>
// XXX: this is an ugly hack because we don't support mutexes
extern int32 gIRSInitKey;
extern int32 gGaiStrerrorKey;
class TLSInit {
public:
TLSInit();
};
TLSInit::TLSInit()
{
gIRSInitKey = tls_allocate();
gGaiStrerrorKey = tls_allocate();
}
static TLSInit __tlsinit_hack;

View File

@ -1,261 +0,0 @@
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* ethers(3) a la Sun.
* Originally Written by Roland McGrath <roland@frob.com> 10/14/93.
* Substantially modified by Todd C. Miller <Todd.Miller@courtesan.com>
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <sys/param.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifdef YP
#include <rpcsvc/ypclnt.h>
#endif
#include "netdb.h" /* for MAXHOSTNAMELEN */
#ifndef _PATH_ETHERS
#define _PATH_ETHERS "/etc/ethers"
#endif
static char * _ether_aton (char *, struct ether_addr *);
char *ether_ntoa(struct ether_addr *e)
{
static char a[] = "xx:xx:xx:xx:xx:xx";
if (e->ether_addr_octet[0] > 0xFF || e->ether_addr_octet[1] > 0xFF ||
e->ether_addr_octet[2] > 0xFF || e->ether_addr_octet[3] > 0xFF ||
e->ether_addr_octet[4] > 0xFF || e->ether_addr_octet[5] > 0xFF) {
errno = EINVAL;
return (NULL);
}
(void)sprintf(a, "%02x:%02x:%02x:%02x:%02x:%02x",
e->ether_addr_octet[0], e->ether_addr_octet[1],
e->ether_addr_octet[2], e->ether_addr_octet[3],
e->ether_addr_octet[4], e->ether_addr_octet[5]);
return (a);
}
static char *_ether_aton(char *s, struct ether_addr *e)
{
int i;
long l;
char *pp;
while (isspace(*s))
s++;
/* expect 6 hex octets separated by ':' or space/NUL if last octet */
for (i = 0; i < 6; i++) {
l = strtol(s, &pp, 16);
if (pp == s || l > 0xFF || l < 0)
return (NULL);
if (!(*pp == ':' || (i == 5 && (isspace(*pp) || *pp == '\0'))))
return (NULL);
e->ether_addr_octet[i] = (u_char)l;
s = pp + 1;
}
/* return character after the octets ala strtol(3) */
return (pp);
}
struct ether_addr *ether_aton(char *s)
{
static struct ether_addr n;
return (_ether_aton(s, &n) ? &n : NULL);
}
int ether_ntohost(char *hostname, struct ether_addr *e)
{
FILE *f;
char buf[BUFSIZ+1], *p;
size_t len;
struct ether_addr try;
char lbuf[80];
#ifdef YP
char trybuf[sizeof("xx:xx:xx:xx:xx:xx")];
int trylen;
#endif
if (e->ether_addr_octet[0] > 0xFF || e->ether_addr_octet[1] > 0xFF ||
e->ether_addr_octet[2] > 0xFF || e->ether_addr_octet[3] > 0xFF ||
e->ether_addr_octet[4] > 0xFF || e->ether_addr_octet[5] > 0xFF) {
errno = EINVAL;
return (-1);
}
#ifdef YP
sprintf(trybuf, "%x:%x:%x:%x:%x:%x",
e->ether_addr_octet[0], e->ether_addr_octet[1],
e->ether_addr_octet[2], e->ether_addr_octet[3],
e->ether_addr_octet[4], e->ether_addr_octet[5]);
trylen = strlen(trybuf);
#endif
f = fopen(_PATH_ETHERS, "r");
if (f == NULL)
return (-1);
while (fgets(lbuf, 80, f) != NULL) {
len = strlen(lbuf);
p = lbuf;
if (p[len-1] == '\n')
len--;
if (len > sizeof(buf) - 2)
continue;
(void)memcpy(buf, p, len);
buf[len] = '\n'; /* code assumes newlines later on */
buf[len+1] = '\0';
#ifdef YP
/* A + in the file means try YP now. */
if (!strncmp(buf, "+\n", sizeof(buf))) {
char *ypbuf, *ypdom;
int ypbuflen;
if (yp_get_default_domain(&ypdom))
continue;
if (yp_match(ypdom, "ethers.byaddr", trybuf,
trylen, &ypbuf, &ypbuflen))
continue;
if (ether_line(ypbuf, &try, hostname) == 0) {
free(ypbuf);
(void)fclose(f);
return (0);
}
free(ypbuf);
continue;
}
#endif
if (ether_line(buf, &try, hostname) == 0 &&
memcmp((void *)&try, (void *)e, sizeof(try)) == 0) {
(void)fclose(f);
return (0);
}
}
(void)fclose(f);
errno = ENOENT;
return (-1);
}
int
ether_hostton(hostname, e)
char *hostname;
struct ether_addr *e;
{
FILE *f;
char buf[BUFSIZ+1], *p;
char try[MAXHOSTNAMELEN];
size_t len;
char lbuf[80];
#ifdef YP
int hostlen = strlen(hostname);
#endif
f = fopen(_PATH_ETHERS, "r");
if (f==NULL)
return (-1);
while (fgets(lbuf, 80, f) != NULL) {
len = strlen(lbuf);
p = lbuf;
if (p[len-1] == '\n')
len--;
if (len > sizeof(buf) - 2)
continue;
memcpy(buf, p, len);
buf[len] = '\n'; /* code assumes newlines later on */
buf[len+1] = '\0';
#ifdef YP
/* A + in the file means try YP now. */
if (!strncmp(buf, "+\n", sizeof(buf))) {
char *ypbuf, *ypdom;
int ypbuflen;
if (yp_get_default_domain(&ypdom))
continue;
if (yp_match(ypdom, "ethers.byname", hostname, hostlen,
&ypbuf, &ypbuflen))
continue;
if (ether_line(ypbuf, e, try) == 0) {
free(ypbuf);
(void)fclose(f);
return (0);
}
free(ypbuf);
continue;
}
#endif
if (ether_line(buf, e, try) == 0 && strcmp(hostname, try) == 0) {
(void)fclose(f);
return (0);
}
}
(void)fclose(f);
errno = ENOENT;
return (-1);
}
int ether_line(char *line, struct ether_addr *e, char *hostname)
{
char *p;
size_t n;
/* Parse "xx:xx:xx:xx:xx:xx" */
if ((p = _ether_aton(line, e)) == NULL || (*p != ' ' && *p != '\t'))
goto bad;
/* Now get the hostname */
while (isspace(*p))
p++;
if (*p == '\0')
goto bad;
n = strcspn(p, " \t\n");
if (n >= MAXHOSTNAMELEN)
goto bad;
strncpy(hostname, p, n + 1);
return (0);
bad:
errno = EINVAL;
return (-1);
}

View File

@ -1,62 +0,0 @@
#ifndef LINT
static const char rcsid[] = "$Id: gettimeofday.c,v 1.1.2.2 2002/07/12 00:49:51 marka Exp $";
#endif
#include "port_before.h"
#include <stdio.h>
#include <syslog.h>
#include <sys/time.h>
#include "port_after.h"
#if !defined(NEED_GETTIMEOFDAY)
/*
* gettimeofday() occasionally returns invalid tv_usec on some platforms.
*/
#define MILLION 1000000
#undef gettimeofday
int
isc__gettimeofday(struct timeval *tp, struct timezone *tzp) {
int res;
res = gettimeofday(tp, tzp);
if (res < 0)
return (res);
if (tp == NULL)
return (res);
if (tp->tv_usec < 0) {
do {
tp->tv_usec += MILLION;
tp->tv_sec--;
} while (tp->tv_usec < 0);
goto log;
} else if (tp->tv_usec > MILLION) {
do {
tp->tv_usec -= MILLION;
tp->tv_sec++;
} while (tp->tv_usec > MILLION);
goto log;
}
return (res);
log:
syslog(LOG_ERR, "gettimeofday: tv_usec out of range\n");
return (res);
}
#else
int
gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp) {
time_t clock, time(time_t *);
if (time(&clock) == (time_t) -1)
return (-1);
if (tvp) {
tvp->tv_sec = clock;
tvp->tv_usec = 0;
}
if (tzp) {
tzp->tz_minuteswest = 0;
tzp->tz_dsttime = 0;
}
return (0);
}
#endif /*NEED_GETTIMEOFDAY*/

View File

@ -1,155 +0,0 @@
/*-
* Copyright (c) 1990, 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 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
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/types.h>
#include <kernel/OS.h>
#include <sys/socket.h>
#include <net/if_dl.h>
#include <string.h>
/* States*/
#define NAMING 0
#define GOTONE 1
#define GOTTWO 2
#define RESET 3
/* Inputs */
#define DIGIT (4*0)
#define END (4*1)
#define DELIM (4*2)
#define LETTER (4*3)
void
link_addr(addr, sdl)
register const char *addr;
register struct sockaddr_dl *sdl;
{
register char *cp = sdl->sdl_data;
char *cplim = sdl->sdl_len + (char *)sdl;
register int byte = 0, state = NAMING, newv = 0;
memset((char *)&sdl->sdl_family, 0, sdl->sdl_len - 1);
sdl->sdl_family = AF_LINK;
do {
state &= ~LETTER;
if ((*addr >= '0') && (*addr <= '9')) {
newv = *addr - '0';
} else if ((*addr >= 'a') && (*addr <= 'f')) {
newv = *addr - 'a' + 10;
} else if ((*addr >= 'A') && (*addr <= 'F')) {
newv = *addr - 'A' + 10;
} else if (*addr == 0) {
state |= END;
} else if (state == NAMING &&
(((*addr >= 'A') && (*addr <= 'Z')) ||
((*addr >= 'a') && (*addr <= 'z'))))
state |= LETTER;
else
state |= DELIM;
addr++;
switch (state /* | INPUT */) {
case NAMING | DIGIT:
case NAMING | LETTER:
*cp++ = addr[-1];
continue;
case NAMING | DELIM:
state = RESET;
sdl->sdl_nlen = cp - sdl->sdl_data;
continue;
case GOTTWO | DIGIT:
*cp++ = byte;
/* FALLTHROUGH */
case RESET | DIGIT:
state = GOTONE;
byte = newv;
continue;
case GOTONE | DIGIT:
state = GOTTWO;
byte = newv + (byte << 4);
continue;
default: /* | DELIM */
state = RESET;
*cp++ = byte;
byte = 0;
continue;
case GOTONE | END:
case GOTTWO | END:
*cp++ = byte;
/* FALLTHROUGH */
case RESET | END:
break;
}
break;
} while (cp < cplim);
sdl->sdl_alen = cp - LLADDR(sdl);
newv = cp - (char *)sdl;
if (newv > (int) sizeof(*sdl))
sdl->sdl_len = newv;
return;
}
static char hexlist[] = "0123456789abcdef";
char *
link_ntoa(sdl)
register const struct sockaddr_dl *sdl;
{
static char obuf[64];
register char *out = obuf;
register int i;
register u_char *in = (u_char *)LLADDR(sdl);
u_char *inlim = in + sdl->sdl_alen;
int firsttime = 1;
if (sdl->sdl_nlen) {
memcpy(obuf, sdl->sdl_data, sdl->sdl_nlen);
out += sdl->sdl_nlen;
if (sdl->sdl_alen)
*out++ = ':';
}
while (in < inlim) {
if (firsttime)
firsttime = 0;
else
*out++ = '.';
i = *in++;
if (i > 0xf) {
out[1] = hexlist[i & 0xf];
i >>= 4;
out[0] = hexlist[i];
out += 2;
} else
*out++ = hexlist[i];
}
*out = 0;
return (obuf);
}

View File

@ -0,0 +1,16 @@
Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
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.
$Id: COPYRIGHT,v 1.3 2009/01/20 23:49:22 tbox Exp $

View File

@ -1,14 +1,15 @@
SubDir HAIKU_TOP src kits network dns ;
SubDir HAIKU_TOP src kits network libbind ;
SetSubDirSupportedPlatforms haiku ;
UseHeaders [ FDirName $(SUBDIR) headers ] : true ;
UseHeaders [ FDirName $(SUBDIR) include ] : true ;
SubDirSysHdrs $(SUBDIR) ;
# private sources for this port
SEARCH_SOURCE += [ FDirName $(SUBDIR) src ] ;
# BIND sources
SEARCH_SOURCE += [ FDirName $(SUBDIR) bsd ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) dst ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) inet ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) irs ] ;
@ -18,20 +19,20 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) resolv ] ;
{
# we want to have the xxx_r functions, too
local defines = _REENTRANT=1 NO_SOCKADDR_UN=1 ;
local defines = _REENTRANT=1 USE_MD5=1 ;
defines = [ FDefines $(defines) ] ;
SubDirCcFlags $(defines) ;
SubDirC++Flags $(defines) ;
}
MergeObject <libnetwork_dns>dns_dst.o :
MergeObject <libbind>libbind_dst.o :
dst_api.c
hmac_link.c
md5_dgst.c
support.c
;
MergeObject <libnetwork_dns>dns_inet.o :
MergeObject <libbind>libbind_inet.o :
inet_addr.c
inet_cidr_ntop.c
inet_cidr_pton.c
@ -49,7 +50,7 @@ MergeObject <libnetwork_dns>dns_inet.o :
nsap_addr.c
;
MergeObject <libnetwork_dns>dns_irs.o :
MergeObject <libbind>libbind_irs.o :
dns.c
dns_ho.c
dns_nw.c
@ -94,7 +95,7 @@ MergeObject <libnetwork_dns>dns_irs.o :
util.c
;
MergeObject <libnetwork_dns>dns_isc.o :
MergeObject <libbind>libbind_isc.o :
assertions.c
base64.c
bitncmp.c
@ -115,7 +116,7 @@ MergeObject <libnetwork_dns>dns_isc.o :
tree.c
;
MergeObject <libnetwork_dns>dns_nameser.o :
MergeObject <libbind>libbind_nameser.o :
ns_date.c
ns_name.c
ns_netint.c
@ -127,8 +128,9 @@ MergeObject <libnetwork_dns>dns_nameser.o :
ns_verify.c
;
MergeObject <libnetwork_dns>dns_resolv.o :
MergeObject <libbind>libbind_resolv.o :
herror.c
mtctxres.c
res_comp.c
res_data.c
res_debug.c
@ -142,8 +144,7 @@ MergeObject <libnetwork_dns>dns_resolv.o :
res_update.c
;
MergeObject <libnetwork_dns>dns_private.o :
MergeObject <libbind>libbind_private.o :
# private functions
TLSInit.cpp
strsep.c
;

View File

@ -1,6 +1,6 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "strsep.c 8.1 (Berkeley) 6/4/93";
static const char rcsid[] = "$Id: strsep.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: strsep.c,v 1.2 2005/04/27 04:56:12 sra Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@ -46,7 +46,7 @@ static const char rcsid[] = "$Id: strsep.c 15570 2005-12-16 22:38:13Z wkornew $"
int __strsep_unneeded__;
#else
/*
/*%
* Get next token from string *stringp, where tokens are possibly-empty
* strings separated by characters from delim.
*
@ -84,3 +84,5 @@ strsep(char **stringp, const char *delim) {
}
#endif /*NEED_STRSEP*/
/*! \file */

View File

@ -1,22 +1,34 @@
/* config.h. Generated by configure. */
/* config.h. Generated from config.h.in by configure. */
/* #undef _SOCKADDR_LEN */
#define HAVE_FCNTL_H 1
/* #undef HAVE_PATHS_H */
#define HAVE_PATHS_H 1
#define HAVE_INTTYPES_H 1
/* #undef HAVE_STROPTS_H */
/* #undef HAVE_SYS_TIMERS_H */
#define HAVE_SYS_SELECT_H 1
#define HAVE_MEMORY_H 1
/* #undef SYS_CDEFS_H */
/* #undef _POSIX_PTHREAD_SEMANTICS */
/* #undef POSIX_GETPWUID_R */
/* #undef POSIX_GETPWNAM_R */
/* #undef POSIX_GETGRGID_R */
/* #undef POSIX_GETGRNAM_R */
#define HAVE_MEMMOVE 1
#define HAVE_MEMCHR 1
/* #undef SPRINTF_CHAR */
/* #undef VSPRINTF_CHAR */
#define USE_SYSERROR_LIST 1
/* #undef NEED_STRTOUL */
/* #undef NEED_SUN4PROTOS */
/* #undef REENABLE_SEND */
#define NEED_SETGROUPENT 1
/* #undef NEED_GETGROUPLIST */
/* define if prototype for getgrnam_r() is required */
#define NEED_GETGRNAM_R 1
#define NEED_GETGRGID_R 1
/*#define NEED_GETGRENT_R 1*/
/* #undef NEED_GETGRNAM_R */
/* #undef NEED_GETGRGID_R */
/* #undef NEED_GETGRENT_R */
#define NEED_SETGRENT_R 1
#define NEED_ENDGRENT_R 1
@ -24,18 +36,21 @@
/* #undef NEED_SETNETGRENT_R */
#define NEED_ENDNETGRENT_R 1
#define NEED_GETPWNAM_R 1
#define NEED_GETPWUID_R 1
/* #undef NEED_GETPWNAM_R */
/* #undef NEED_GETPWUID_R */
#define NEED_SETPWENT_R 1
#define NEED_SETPASSENT_R 1
#define NEED_SETPWENT_R 1
/*#define NEED_GETPWENT_R 1*/
/* #undef NEED_GETPWENT_R */
#define NEED_ENDPWENT_R 1
#define NEED_SETPASSENT 1
/* #undef HAS_PW_CLASS */
/* #undef ssize_t */
/* #undef uintptr_t */
/* Shut up warnings about sputaux in stdio.h on BSD/OS pre-4.1 */
/* #undef SHUTUP_SPUTAUX */
#ifdef SHUTUP_SPUTAUX
@ -43,7 +58,7 @@ struct __sFILE;
extern __inline int __sputaux(int _c, struct __sFILE *_p);
#endif
/* #undef BROKEN_IN6ADDR_INIT_MACROS */
/* #undef HAVE_STRLCAT */
#define HAVE_STRLCAT 1
/* Shut up warnings about missing braces */
/* #undef SHUTUP_MUTEX_INITIALIZER */
#ifdef SHUTUP_MUTEX_INITIALIZER

View File

@ -1,3 +1,7 @@
#ifndef LINT
static const char rcsid[] = "$Header: /proj/cvs/prod/libbind/dst/dst_api.c,v 1.17 2007/09/24 17:18:25 each Exp $";
#endif
/*
* Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
*
@ -74,7 +78,7 @@ static DST_KEY *dst_s_get_key_struct(const char *name, const int alg,
const int flags, const int protocol,
const int bits);
/*
/*%
* dst_init
* This function initializes the Digital Signature Toolkit.
* Right now, it just checks the DSTKEYPATH environment variable.
@ -120,7 +124,7 @@ dst_init()
dst_hmac_md5_init();
}
/*
/*%
* dst_check_algorithm
* This function determines if the crypto system for the specified
* algorithm is present.
@ -139,7 +143,7 @@ dst_check_algorithm(const int alg)
return (dst_t_func[alg] != NULL);
}
/*
/*%
* dst_s_get_key_struct
* This function allocates key structure and fills in some of the
* fields of the structure.
@ -159,13 +163,17 @@ dst_s_get_key_struct(const char *name, const int alg, const int flags,
{
DST_KEY *new_key = NULL;
if (dst_check_algorithm(alg)) /* make sure alg is available */
if (dst_check_algorithm(alg)) /*%< make sure alg is available */
new_key = (DST_KEY *) malloc(sizeof(*new_key));
if (new_key == NULL)
return (NULL);
memset(new_key, 0, sizeof(*new_key));
new_key->dk_key_name = strdup(name);
if (new_key->dk_key_name == NULL) {
free(new_key);
return (NULL);
}
new_key->dk_alg = alg;
new_key->dk_flags = flags;
new_key->dk_proto = protocol;
@ -175,7 +183,7 @@ dst_s_get_key_struct(const char *name, const int alg, const int flags,
return (new_key);
}
/*
/*%
* dst_compare_keys
* Compares two keys for equality.
* Parameters
@ -201,8 +209,7 @@ dst_compare_keys(const DST_KEY *key1, const DST_KEY *key2)
return (key1->dk_func->compare(key1, key2));
}
/*
/*%
* dst_sign_data
* An incremental signing function. Data is signed in steps.
* First the context must be initialized (SIG_MODE_INIT).
@ -228,8 +235,8 @@ dst_compare_keys(const DST_KEY *key1, const DST_KEY *key2)
* sig_len Length of the signature field in bytes.
* Return
* 0 Successfull INIT or Update operation
* >0 success FINAL (sign) operation
* <0 failure
* &gt;0 success FINAL (sign) operation
* &lt;0 failure
*/
int
@ -249,8 +256,7 @@ dst_sign_data(const int mode, DST_KEY *in_key, void **context,
return (UNKNOWN_KEYALG);
}
/*
/*%
* dst_verify_data
* An incremental verify function. Data is verified in steps.
* First the context must be initialized (SIG_MODE_INIT).
@ -292,8 +298,7 @@ dst_verify_data(const int mode, DST_KEY *in_key, void **context,
signature, sig_len));
}
/*
/*%
* dst_read_private_key
* Access a private key. First the list of private keys that have
* already been read in is searched, then the key accessed on disk.
@ -322,7 +327,7 @@ dst_read_key(const char *in_keyname, const u_int16_t in_id,
char keyname[PATH_MAX];
DST_KEY *dg_key = NULL, *pubkey = NULL;
if (!dst_check_algorithm(in_alg)) { /* make sure alg is available */
if (!dst_check_algorithm(in_alg)) { /*%< make sure alg is available */
EREPORT(("dst_read_private_key(): Algorithm %d not suppored\n",
in_alg));
return (NULL);
@ -332,7 +337,10 @@ dst_read_key(const char *in_keyname, const u_int16_t in_id,
if (in_keyname == NULL) {
EREPORT(("dst_read_private_key(): Null key name passed in\n"));
return (NULL);
} else
} else if (strlen(in_keyname) >= sizeof(keyname)) {
EREPORT(("dst_read_private_key(): keyname too big\n"));
return (NULL);
} else
strcpy(keyname, in_keyname);
/* before I read in the public key, check if it is allowed to sign */
@ -343,7 +351,7 @@ dst_read_key(const char *in_keyname, const u_int16_t in_id,
return pubkey;
if (!(dg_key = dst_s_get_key_struct(keyname, pubkey->dk_alg,
pubkey->dk_flags, pubkey->dk_proto,
pubkey->dk_flags, pubkey->dk_proto,
0)))
return (dg_key);
/* Fill in private key and some fields in the general key structure */
@ -351,7 +359,7 @@ dst_read_key(const char *in_keyname, const u_int16_t in_id,
pubkey->dk_alg) == 0)
dg_key = dst_free_key(dg_key);
pubkey = dst_free_key(pubkey);
(void)dst_free_key(pubkey);
return (dg_key);
}
@ -362,7 +370,7 @@ dst_write_key(const DST_KEY *key, const int type)
if (key == NULL)
return (0);
if (!dst_check_algorithm(key->dk_alg)) { /* make sure alg is available */
if (!dst_check_algorithm(key->dk_alg)) { /*%< make sure alg is available */
EREPORT(("dst_write_key(): Algorithm %d not suppored\n",
key->dk_alg));
return (UNSUPPORTED_KEYALG);
@ -379,19 +387,19 @@ dst_write_key(const DST_KEY *key, const int type)
return (priv+pub);
}
/*
/*%
* dst_write_private_key
* Write a private key to disk. The filename will be of the form:
* K<key->dk_name>+<key->dk_alg>+<key->dk_id>.<private key suffix>.
* K&lt;key-&gt;dk_name&gt;+&lt;key-&gt;dk_alg+&gt;&lt;key-d&gt;k_id.&gt;&lt;private key suffix&gt;.
* If there is already a file with this name, an error is returned.
*
* Parameters
* key A DST managed key structure that contains
* all information needed about a key.
* Return
* >= 0 Correct behavior. Returns length of encoded key value
* &gt;= 0 Correct behavior. Returns length of encoded key value
* written to disk.
* < 0 error.
* &lt; 0 error.
*/
static int
@ -406,8 +414,7 @@ dst_s_write_private_key(const DST_KEY *key)
if (key == NULL)
return (-1);
if (key->dk_KEY_struct == NULL)
return (0); /* null key has no private key */
return (0); /*%< null key has no private key */
if (key->dk_func == NULL || key->dk_func->to_file_fmt == NULL) {
EREPORT(("dst_write_private_key(): Unsupported operation %d\n",
key->dk_alg));
@ -427,6 +434,7 @@ dst_s_write_private_key(const DST_KEY *key)
if ((nn = fwrite(encoded_block, 1, len, fp)) != len) {
EREPORT(("dst_write_private_key(): Write failure on %s %d != %d errno=%d\n",
file, len, nn, errno));
fclose(fp);
return (-5);
}
fclose(fp);
@ -439,12 +447,12 @@ dst_s_write_private_key(const DST_KEY *key)
return (len);
}
/*
/*%
*
* dst_read_public_key
* Read a public key from disk and store in a DST key structure.
* Parameters
* in_name K<in_name><in_id>.<public key suffix> is the
* in_name K&lt;in_name&gt;&lt;in_id&gt;.&lt;public key suffix&gt; is the
* filename of the key file to be read.
* Returns
* NULL If the key does not exist or no name is supplied.
@ -473,7 +481,7 @@ dst_s_read_public_key(const char *in_name, const u_int16_t in_id, int in_alg)
/*
* Open the file and read it's formatted contents up to key
* File format:
* domain.name [ttl] [IN] KEY <flags> <protocol> <algorithm> <key>
* domain.name [ttl] [IN] KEY &lt;flags&gt; &lt;protocol&gt; &lt;algorithm&gt; &lt;key&gt;
* flags, proto, alg stored as decimal (or hex numbers FIXME).
* (FIXME: handle parentheses for line continuation.)
*/
@ -520,7 +528,7 @@ dst_s_read_public_key(const char *in_name, const u_int16_t in_id, int in_alg)
while ((c = getc(fp)) != EOF)
if (!isspace(c))
break;
ungetc(c, fp); /* return the charcter to the input field */
ungetc(c, fp); /*%< return the charcter to the input field */
/* Handle hex!! FIXME. */
if (fscanf(fp, "%d %d %d", &flags, &proto, &alg) != 3) {
@ -563,8 +571,7 @@ dst_s_read_public_key(const char *in_name, const u_int16_t in_id, int in_alg)
return dst_buffer_to_key(in_name, alg, flags, proto, deckey, dlen);
}
/*
/*%
* dst_write_public_key
* Write a key to disk in DNS format.
* Parameters
@ -618,8 +625,7 @@ dst_s_write_public_key(const DST_KEY *key)
return (1);
}
/*
/*%
* dst_dnskey_to_public_key
* This function converts the contents of a DNS KEY RR into a DST
* key structure.
@ -640,19 +646,21 @@ dst_dnskey_to_key(const char *in_name, const u_char *rdata, const int len)
int alg ;
int start = DST_KEY_START;
if (rdata == NULL || len <= DST_KEY_ALG) /* no data */
if (rdata == NULL || len <= DST_KEY_ALG) /*%< no data */
return (NULL);
alg = (u_int8_t) rdata[DST_KEY_ALG];
if (!dst_check_algorithm(alg)) { /* make sure alg is available */
if (!dst_check_algorithm(alg)) { /*%< make sure alg is available */
EREPORT(("dst_dnskey_to_key(): Algorithm %d not suppored\n",
alg));
return (NULL);
}
if ((key_st = dst_s_get_key_struct(in_name, alg, 0, 0, 0)) == NULL)
return (NULL);
if (in_name == NULL)
return (NULL);
if ((key_st = dst_s_get_key_struct(in_name, alg, 0, 0, 0)) == NULL)
return (NULL);
key_st->dk_id = dst_s_dns_key_id(rdata, len);
key_st->dk_flags = dst_s_get_int16(rdata);
key_st->dk_proto = (u_int16_t) rdata[DST_KEY_PROT];
@ -678,8 +686,7 @@ dst_dnskey_to_key(const char *in_name, const u_char *rdata, const int len)
return (key_st);
}
/*
/*%
* dst_public_key_to_dnskey
* Function to encode a public key into DNS KEY wire format
* Parameters
@ -701,7 +708,7 @@ dst_key_to_dnskey(const DST_KEY *key, u_char *out_storage,
if (key == NULL)
return (-1);
if (!dst_check_algorithm(key->dk_alg)) { /* make sure alg is available */
if (!dst_check_algorithm(key->dk_alg)) { /*%< make sure alg is available */
EREPORT(("dst_key_to_dnskey(): Algorithm %d not suppored\n",
key->dk_alg));
return (UNSUPPORTED_KEYALG);
@ -714,7 +721,7 @@ dst_key_to_dnskey(const DST_KEY *key, u_char *out_storage,
out_storage[loc++] = (u_char) key->dk_proto;
out_storage[loc++] = (u_char) key->dk_alg;
if (key->dk_flags > 0xffff) { /* Extended flags */
if (key->dk_flags > 0xffff) { /*%< Extended flags */
val = (u_int16_t)((key->dk_flags >> 16) & 0xffff);
dst_s_put_int16(&out_storage[loc], val);
loc += 2;
@ -735,8 +742,7 @@ dst_key_to_dnskey(const DST_KEY *key, u_char *out_storage,
return (-1);
}
/*
/*%
* dst_buffer_to_key
* Function to encode a string of raw data into a DST key
* Parameters
@ -748,30 +754,28 @@ dst_key_to_dnskey(const DST_KEY *key, u_char *out_storage,
* NON-NULL the DST key
*/
DST_KEY *
dst_buffer_to_key(const char *key_name, /* name of the key */
const int alg, /* algorithm */
const int flags, /* dns flags */
const int protocol, /* dns protocol */
const u_char *key_buf, /* key in dns wire fmt */
const int key_len) /* size of key */
dst_buffer_to_key(const char *key_name, /*!< name of the key */
const int alg, /*!< algorithm */
const int flags, /*!< dns flags */
const int protocol, /*!< dns protocol */
const u_char *key_buf, /*!< key in dns wire fmt */
const int key_len) /*!< size of key */
{
DST_KEY *dkey = NULL;
int dnslen;
u_char dns[2048];
if (!dst_check_algorithm(alg)) { /* make sure alg is available */
if (!dst_check_algorithm(alg)) { /*%< make sure alg is available */
EREPORT(("dst_buffer_to_key(): Algorithm %d not suppored\n", alg));
return (NULL);
}
dkey = dst_s_get_key_struct(key_name, alg, flags,
protocol, -1);
dkey = dst_s_get_key_struct(key_name, alg, flags, protocol, -1);
if (dkey == NULL)
return (NULL);
if (dkey->dk_func == NULL || dkey->dk_func->from_dns_key == NULL)
return NULL;
if (dkey == NULL || dkey->dk_func == NULL ||
dkey->dk_func->from_dns_key == NULL)
return (dst_free_key(dkey));
if (dkey->dk_func->from_dns_key(dkey, key_buf, key_len) < 0) {
EREPORT(("dst_buffer_to_key(): dst_buffer_to_hmac failed\n"));
@ -799,8 +803,7 @@ dst_key_to_buffer(DST_KEY *key, u_char *out_buff, int buf_len)
return (0);
}
/*
/*%
* dst_s_read_private_key_file
* Function reads in private key from a file.
* Fills out the KEY structure.
@ -874,14 +877,14 @@ dst_s_read_private_key_file(char *name, DST_KEY *pk_key, u_int16_t in_id,
"dst_s_read_private_key_file(): Keyfile %s version higher than mine %d.%d MAY FAIL\n",
name, file_major, file_minor));
while (*p++ != '\n') ; /* skip to end of line */
while (*p++ != '\n') ; /*%< skip to end of line */
if (!dst_s_verify_str((const char **) (void *)&p, "Algorithm: "))
goto fail;
if (sscanf((char *)p, "%d", &alg) != 1)
goto fail;
while (*p++ != '\n') ; /* skip to end of line */
while (*p++ != '\n') ; /*%< skip to end of line */
if (pk_key->dk_key_name && !strcmp(pk_key->dk_key_name, name))
SAFE_FREE2(pk_key->dk_key_name, strlen(pk_key->dk_key_name));
@ -914,34 +917,34 @@ dst_s_read_private_key_file(char *name, DST_KEY *pk_key, u_int16_t in_id,
return (0);
}
/*
* dst_generate_key
/*%
* Generate and store a public/private keypair.
* Keys will be stored in formatted files.
*
* Parameters
* name Name of the new key. Used to create key files
* K<name>+<alg>+<id>.public and K<name>+<alg>+<id>.private.
* bits Size of the new key in bits.
* exp What exponent to use:
* 0 use exponent 3
* non-zero use Fermant4
* flags The default value of the DNS Key flags.
* The DNS Key RR Flag field is defined in RFC 2065,
&
*\par name Name of the new key. Used to create key files
*\li K&lt;name&gt;+&lt;alg&gt;+&lt;id&gt;.public and K&lt;name&gt;+&lt;alg&gt;+&lt;id&gt;.private.
*\par bits Size of the new key in bits.
*\par exp What exponent to use:
*\li 0 use exponent 3
*\li non-zero use Fermant4
*\par flags The default value of the DNS Key flags.
*\li The DNS Key RR Flag field is defined in RFC2065,
* section 3.3. The field has 16 bits.
* protocol
* Default value of the DNS Key protocol field.
* The DNS Key protocol field is defined in RFC 2065,
*\par protocol
*\li Default value of the DNS Key protocol field.
*\li The DNS Key protocol field is defined in RFC2065,
* section 3.4. The field has 8 bits.
* alg What algorithm to use. Currently defined:
* KEY_RSA 1
* KEY_DSA 3
* KEY_HMAC 157
* out_id The key tag is returned.
*\par alg What algorithm to use. Currently defined:
*\li KEY_RSA 1
*\li KEY_DSA 3
*\li KEY_HMAC 157
*\par out_id The key tag is returned.
*
* Return
* NULL Failure
* non-NULL the generated key pair
*\li NULL Failure
*\li non-NULL the generated key pair
* Caller frees the result, and its dk_name pointer.
*/
DST_KEY *
@ -949,14 +952,13 @@ dst_generate_key(const char *name, const int bits, const int exp,
const int flags, const int protocol, const int alg)
{
DST_KEY *new_key = NULL;
int res;
int dnslen;
u_char dns[2048];
if (name == NULL)
return (NULL);
if (!dst_check_algorithm(alg)) { /* make sure alg is available */
if (!dst_check_algorithm(alg)) { /*%< make sure alg is available */
EREPORT(("dst_generate_key(): Algorithm %d not suppored\n", alg));
return (NULL);
}
@ -964,14 +966,14 @@ dst_generate_key(const char *name, const int bits, const int exp,
new_key = dst_s_get_key_struct(name, alg, flags, protocol, bits);
if (new_key == NULL)
return (NULL);
if (bits == 0) /* null key we are done */
if (bits == 0) /*%< null key we are done */
return (new_key);
if (new_key->dk_func == NULL || new_key->dk_func->generate == NULL) {
EREPORT(("dst_generate_key_pair():Unsupported algorithm %d\n",
alg));
return (dst_free_key(new_key));
}
if ((res = new_key->dk_func->generate(new_key, exp)) <= 0) {
if (new_key->dk_func->generate(new_key, exp) <= 0) {
EREPORT(("dst_generate_key_pair(): Key generation failure %s %d %d %d\n",
new_key->dk_key_name, new_key->dk_alg,
new_key->dk_key_size, exp));
@ -987,12 +989,11 @@ dst_generate_key(const char *name, const int bits, const int exp,
return (new_key);
}
/*
* dst_free_key
/*%
* Release all data structures pointed to by a key structure.
*
* Parameters
* f_key Key structure to be freed.
*\li f_key Key structure to be freed.
*/
DST_KEY *
@ -1007,7 +1008,6 @@ dst_free_key(DST_KEY *f_key)
else {
EREPORT(("dst_free_key(): Unknown key alg %d\n",
f_key->dk_alg));
free(f_key->dk_KEY_struct); /* SHOULD NOT happen */
}
if (f_key->dk_KEY_struct) {
free(f_key->dk_KEY_struct);
@ -1019,13 +1019,14 @@ dst_free_key(DST_KEY *f_key)
return (NULL);
}
/*
* dst_sig_size
/*%
* Return the maximim size of signature from the key specified in bytes
*
* Parameters
* key
*\li key
*
* Returns
* bytes
* \li bytes
*/
int
dst_sig_size(DST_KEY *key) {
@ -1043,3 +1044,5 @@ dst_sig_size(DST_KEY *key) {
return -1;
}
}
/*! \file */

View File

@ -19,25 +19,29 @@
*/
#include <limits.h>
#include <sys/param.h>
#include <sys/types.h>
#if (!defined(BSD)) || (BSD < 199306)
# include <sys/bitypes.h>
#else
# include <sys/types.h>
#endif
#ifndef PATH_MAX
# ifdef POSIX_PATH_MAX
# define PATH_MAX POSIX_PATH_MAX
# else
# define PATH_MAX 255 /* this is the value of POSIX_PATH_MAX */
# define PATH_MAX 255 /*%< this is the value of POSIX_PATH_MAX */
# endif
#endif
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 */
void *dk_KEY_struct; /* pointer to key in crypto pkg fmt */
struct dst_func *dk_func; /* point to cryptto pgk specific function table */
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 */
void *dk_KEY_struct; /*%< pointer to key in crypto pkg fmt */
struct dst_func *dk_func; /*%< point to cryptto pgk specific function table */
} DST_KEY;
#define HAS_DST_KEY
@ -99,7 +103,7 @@ extern const char *key_file_fmt_str;
extern const char *dst_path;
#ifndef DST_HASH_SIZE
#define DST_HASH_SIZE 20 /* RIPEMD160 and SHA-1 are 20 bytes MD5 is 16 */
#define DST_HASH_SIZE 20 /*%< RIPEMD160 and SHA-1 are 20 bytes MD5 is 16 */
#endif
int dst_bsafe_init(void);
@ -125,7 +129,7 @@ int dst_s_build_filename( char *filename, const char *name,
FILE *dst_s_fopen (const char *filename, const char *mode, int perm);
/*
/*%
* read and write network byte order into u_int?_t
* all of these should be retired
*/
@ -148,3 +152,4 @@ dst_s_dump(const int mode, const u_char *data, const int size,
#endif /* DST_INTERNAL_H */
/*! \file */

View File

@ -1,6 +1,6 @@
#ifdef HMAC_MD5
#ifndef LINT
static const char rcsid[] = "$Header: /proj/cvs/prod/bind9/lib/bind/dst/hmac_link.c,v 1.2.2.1 2003/06/27 03:51:36 marka Exp $";
static const char rcsid[] = "$Header: /proj/cvs/prod/libbind/dst/hmac_link.c,v 1.8 2007/09/24 17:18:25 each Exp $";
#endif
/*
* Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
@ -19,7 +19,7 @@ static const char rcsid[] = "$Header: /proj/cvs/prod/bind9/lib/bind/dst/hmac_lin
* WITH THE USE OR PERFORMANCE OF THE SOFTWARE.
*/
/*
/*%
* This file contains an implementation of the HMAC-MD5 algorithm.
*/
#include "port_before.h"
@ -36,10 +36,17 @@ static const char rcsid[] = "$Header: /proj/cvs/prod/bind9/lib/bind/dst/hmac_lin
#include <resolv.h>
#include "dst_internal.h"
#ifdef USE_MD5
# include "md5.h"
# ifndef HAVE_MD5
# include "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 */
# define _MD5_H_ 1 /*%< make sure we do not include rsaref md5.h file */
# endif
#endif
@ -57,10 +64,10 @@ typedef struct hmackey {
} HMAC_Key;
/**************************************************************************
/**************************************************************************
* dst_hmac_md5_sign
* Call HMAC signing functions to sign a block of data.
* There are three steps to signing, INIT (initialize structures),
* There are three steps to signing, INIT (initialize structures),
* UPDATE (hash (more) data), FINAL (generate a signature). This
* routine performs one or more of these steps.
* Parameters
@ -71,30 +78,31 @@ typedef struct hmackey {
* len length in bytes of data.
* signature location to store signature.
* sig_len size of the signature location
* returns
* returns
* N Success on SIG_MODE_FINAL = returns signature length in bytes
* 0 Success on SIG_MODE_INIT and UPDATE
* <0 Failure
*/
static int
dst_hmac_md5_sign(const int mode, DST_KEY *d_key, void **context,
const u_char *data, const int len,
dst_hmac_md5_sign(const int mode, DST_KEY *d_key, void **context,
const u_char *data, const int len,
u_char *signature, const int sig_len)
{
HMAC_Key *key;
int sign_len = 0;
MD5_CTX *ctx = NULL;
if (mode & SIG_MODE_INIT)
if (d_key == NULL || d_key->dk_KEY_struct == NULL)
return (-1);
if (mode & SIG_MODE_INIT)
ctx = (MD5_CTX *) malloc(sizeof(*ctx));
else if (context)
ctx = (MD5_CTX *) *context;
if (ctx == NULL)
if (ctx == NULL)
return (-1);
if (d_key == NULL || d_key->dk_KEY_struct == NULL)
return (-1);
key = (HMAC_Key *) d_key->dk_KEY_struct;
if (mode & SIG_MODE_INIT) {
@ -118,20 +126,20 @@ dst_hmac_md5_sign(const int mode, DST_KEY *d_key, void **context,
sign_len = MD5_LEN;
SAFE_FREE(ctx);
}
else {
if (context == NULL)
else {
if (context == NULL)
return (-1);
*context = (void *) ctx;
}
}
return (sign_len);
}
/**************************************************************************
* dst_hmac_md5_verify()
* Calls HMAC verification routines. There are three steps to
* verification, INIT (initialize structures), UPDATE (hash (more) data),
* FINAL (generate a signature). This routine performs one or more of
/**************************************************************************
* dst_hmac_md5_verify()
* Calls HMAC verification routines. There are three steps to
* verification, INIT (initialize structures), UPDATE (hash (more) data),
* FINAL (generate a signature). This routine performs one or more of
* these steps.
* Parameters
* mode SIG_MODE_INIT, SIG_MODE_UPDATE and/or SIG_MODE_FINAL.
@ -140,8 +148,8 @@ dst_hmac_md5_sign(const int mode, DST_KEY *d_key, void **context,
* len length in bytes of data.
* signature signature.
* sig_len length in bytes of signature.
* returns
* 0 Success
* returns
* 0 Success
* <0 Failure
*/
@ -153,14 +161,14 @@ dst_hmac_md5_verify(const int mode, DST_KEY *d_key, void **context,
HMAC_Key *key;
MD5_CTX *ctx = NULL;
if (mode & SIG_MODE_INIT)
if (d_key == NULL || d_key->dk_KEY_struct == NULL)
return (-1);
if (mode & SIG_MODE_INIT)
ctx = (MD5_CTX *) malloc(sizeof(*ctx));
else if (context)
ctx = (MD5_CTX *) *context;
if (ctx == NULL)
return (-1);
if (d_key == NULL || d_key->dk_KEY_struct == NULL)
if (ctx == NULL)
return (-1);
key = (HMAC_Key *) d_key->dk_KEY_struct;
@ -187,16 +195,16 @@ dst_hmac_md5_verify(const int mode, DST_KEY *d_key, void **context,
if (memcmp(digest, signature, MD5_LEN) != 0)
return (VERIFY_FINAL_FAILURE);
}
else {
if (context == NULL)
else {
if (context == NULL)
return (-1);
*context = (void *) ctx;
}
}
return (0);
}
/**************************************************************************
/**************************************************************************
* dst_buffer_to_hmac_md5
* Converts key from raw data to an HMAC Key
* This function gets in a pointer to the data
@ -215,6 +223,7 @@ dst_buffer_to_hmac_md5(DST_KEY *dkey, const u_char *key, const int keylen)
HMAC_Key *hkey = NULL;
MD5_CTX ctx;
int local_keylen = keylen;
u_char tk[MD5_LEN];
if (dkey == NULL || key == NULL || keylen < 0)
return (-1);
@ -227,7 +236,6 @@ dst_buffer_to_hmac_md5(DST_KEY *dkey, const u_char *key, const int keylen)
/* if key is longer than HMAC_LEN bytes reset it to key=MD5(key) */
if (keylen > HMAC_LEN) {
u_char tk[MD5_LEN];
MD5Init(&ctx);
MD5Update(&ctx, key, keylen);
MD5Final(tk, &ctx);
@ -250,13 +258,13 @@ dst_buffer_to_hmac_md5(DST_KEY *dkey, const u_char *key, const int keylen)
}
/**************************************************************************
/**************************************************************************
* dst_hmac_md5_key_to_file_format
* Encodes an HMAC Key into the portable file format.
* Parameters
* hkey HMAC KEY structure
* Parameters
* hkey HMAC KEY structure
* buff output buffer
* buff_len size of output buffer
* buff_len size of output buffer
* Return
* 0 Failure - null input hkey
* -1 Failure - not enough space in output area
@ -265,25 +273,28 @@ dst_buffer_to_hmac_md5(DST_KEY *dkey, const u_char *key, const int keylen)
static int
dst_hmac_md5_key_to_file_format(const DST_KEY *dkey, char *buff,
const int buff_len)
const int buff_len)
{
char *bp;
int len, b_len, i, key_len;
int len, i, key_len;
u_char key[HMAC_LEN];
HMAC_Key *hkey;
if (dkey == NULL || dkey->dk_KEY_struct == NULL)
if (dkey == NULL || dkey->dk_KEY_struct == NULL)
return (0);
if (buff == NULL || buff_len <= (int) strlen(key_file_fmt_str))
return (-1); /* no OR not enough space in output area */
/*
* Using snprintf() would be so much simpler here.
*/
if (buff == NULL ||
buff_len <= (int)(strlen(key_file_fmt_str) +
strlen(KEY_FILE_FORMAT) + 4))
return (-1); /*%< no OR not enough space in output area */
hkey = (HMAC_Key *) dkey->dk_KEY_struct;
memset(buff, 0, buff_len); /* just in case */
memset(buff, 0, buff_len); /*%< just in case */
/* write file header */
sprintf(buff, key_file_fmt_str, KEY_FILE_FORMAT, KEY_HMAC_MD5, "HMAC");
bp = (char *) strchr(buff, '\0');
b_len = buff_len - (bp - buff);
bp = buff + strlen(buff);
memset(key, 0, HMAC_LEN);
for (i = 0; i < HMAC_LEN; i++)
@ -293,32 +304,34 @@ dst_hmac_md5_key_to_file_format(const DST_KEY *dkey, char *buff,
break;
key_len = i + 1;
if (buff_len - (bp - buff) < 6)
return (-1);
strcat(bp, "Key: ");
bp += strlen("Key: ");
b_len = buff_len - (bp - buff);
len = b64_ntop(key, key_len, bp, b_len);
if (len < 0)
len = b64_ntop(key, key_len, bp, buff_len - (bp - buff));
if (len < 0)
return (-1);
bp += len;
if (buff_len - (bp - buff) < 2)
return (-1);
*(bp++) = '\n';
*bp = '\0';
b_len = buff_len - (bp - buff);
return (buff_len - b_len);
return (bp - buff);
}
/**************************************************************************
/**************************************************************************
* dst_hmac_md5_key_from_file_format
* Converts contents of a key file into an HMAC key.
* Parameters
* hkey structure to put key into
* buff buffer containing the encoded key
* Converts contents of a key file into an HMAC key.
* Parameters
* hkey structure to put key into
* buff buffer containing the encoded key
* buff_len the length of the buffer
* Return
* n >= 0 Foot print of the key converted
* n < 0 Error in conversion
* n >= 0 Foot print of the key converted
* n < 0 Error in conversion
*/
static int
@ -327,9 +340,9 @@ dst_hmac_md5_key_from_file_format(DST_KEY *dkey, const char *buff,
{
const char *p = buff, *eol;
u_char key[HMAC_LEN+1]; /* b64_pton needs more than 64 bytes do decode
* it should probably be fixed rather than doing
* this
*/
* it should probably be fixed rather than doing
* this
*/
u_char *tmp;
int key_len, len;
@ -348,9 +361,11 @@ dst_hmac_md5_key_from_file_format(DST_KEY *dkey, const char *buff,
return (-4);
len = eol - p;
tmp = malloc(len + 2);
if (tmp == NULL)
return (-5);
memcpy(tmp, p, len);
*(tmp + len) = 0x0;
key_len = b64_pton((char *)tmp, key, HMAC_LEN+1); /* see above */
key_len = b64_pton((char *)tmp, key, HMAC_LEN+1); /*%< see above */
SAFE_FREE2(tmp, len + 2);
if (dst_buffer_to_hmac_md5(dkey, key, key_len) < 0) {
@ -359,16 +374,16 @@ dst_hmac_md5_key_from_file_format(DST_KEY *dkey, const char *buff,
return (0);
}
/*
* dst_hmac_md5_to_dns_key()
* function to extract hmac key from DST_KEY structure
* intput:
* in_key: HMAC-MD5 key
* output:
/*%
* dst_hmac_md5_to_dns_key()
* function to extract hmac key from DST_KEY structure
* intput:
* in_key: HMAC-MD5 key
* output:
* out_str: buffer to write ot
* out_len: size of output buffer
* out_len: size of output buffer
* returns:
* number of bytes written to output buffer
* number of bytes written to output buffer
*/
static int
dst_hmac_md5_to_dns_key(const DST_KEY *in_key, u_char *out_str,
@ -377,7 +392,7 @@ dst_hmac_md5_to_dns_key(const DST_KEY *in_key, u_char *out_str,
HMAC_Key *hkey;
int i;
if (in_key == NULL || in_key->dk_KEY_struct == NULL ||
out_len <= in_key->dk_key_size || out_str == NULL)
return (-1);
@ -388,7 +403,7 @@ dst_hmac_md5_to_dns_key(const DST_KEY *in_key, u_char *out_str,
return (i);
}
/**************************************************************************
/**************************************************************************
* dst_hmac_md5_compare_keys
* Compare two keys for equality.
* Return
@ -404,7 +419,7 @@ dst_hmac_md5_compare_keys(const DST_KEY *key1, const DST_KEY *key2)
return memcmp(hkey1->hk_ipad, hkey2->hk_ipad, HMAC_LEN);
}
/**************************************************************************
/**************************************************************************
* dst_hmac_md5_free_key_structure
* Frees all (none) dynamically allocated structures in hkey
*/
@ -418,11 +433,11 @@ dst_hmac_md5_free_key_structure(void *key)
}
/***************************************************************************
/***************************************************************************
* dst_hmac_md5_generate_key
* Creates a HMAC key of size size with a maximum size of 63 bytes
* generating a HMAC key larger than 63 bytes makes no sense as that key
* is digested before use.
* generating a HMAC key larger than 63 bytes makes no sense as that key
* is digested before use.
*/
static int
@ -433,12 +448,16 @@ dst_hmac_md5_generate_key(DST_KEY *key, const int nothing)
return (-1);
}
/*
/*%
* dst_hmac_md5_init() Function to answer set up function pointers for HMAC
* related functions
* related functions
*/
int
#ifdef SUNW_LIBMD5
dst_md5_hmac_init()
#else
dst_hmac_md5_init()
#endif
{
if (dst_t_func[KEY_HMAC_MD5] != NULL)
return (1);
@ -458,13 +477,15 @@ dst_hmac_md5_init()
return (1);
}
#else
#else
int __dst_hmac_md5_init(void);
#define dst_hmac_md5_init __dst_hmac_md5_init
int
__dst_hmac_md5_init(void)
dst_hmac_md5_init()
{
return (0);
}
#endif
/*! \file */

View File

@ -59,6 +59,8 @@
#ifndef HEADER_MD5_H
#define HEADER_MD5_H
#ifndef HAVE_MD5
#ifdef __cplusplus
extern "C" {
#endif
@ -70,6 +72,12 @@ extern "C" {
#define MD5_LENGTH_BLOCK 8
#define MD5_DIGEST_LENGTH 16
#define MD5_CTX __bind_MD5_CTX
#define MD5_Init __bind_MD5_Init
#define MD5_Update __bind_MD5_Update
#define MD5_Final __bind_MD5_Final
#define MD5_version __bind_MD5_version
typedef struct MD5state_st
{
unsigned long A,B,C,D;
@ -82,12 +90,10 @@ typedef struct MD5state_st
void MD5_Init(MD5_CTX *c);
void MD5_Update(MD5_CTX *c, const unsigned char *data, unsigned long len);
void MD5_Final(unsigned char *md, MD5_CTX *c);
unsigned char *MD5(unsigned char *d, unsigned long n, unsigned char *md);
#else
void MD5_Init();
void MD5_Update();
void MD5_Final();
unsigned char *MD5();
#endif
/* to provide backward compatabilty to RSAREF calls ogud@tis.com 1997/11/14 */
@ -99,3 +105,8 @@ unsigned char *MD5();
#endif
#endif
#else
#include <sys/md5.h>
#endif /* HAVE_MD5 */
/*! \file */

View File

@ -5,21 +5,21 @@
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -34,10 +34,10 @@
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -49,22 +49,25 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
#ifdef USE_MD5 /* Added by ogud@tis.com 1998/1/26 */
#ifdef USE_MD5 /*%< Added by ogud@tis.com 1998/1/26 */
#include <port_before.h>
#ifndef HAVE_MD5
#include <stdio.h>
#include "md5_locl.h"
#include <port_after.h>
const char *MD5_version="MD5 part of SSLeay 0.8.1 19-Jul-1997";
/* Implemented from RFC1321 The MD5 Message-Digest Algorithm
/*! \file
* \brief
* Implemented from RFC1321 The MD5 Message-Digest Algorithm
*/
#define INIT_DATA_A (unsigned long)0x67452301L
@ -104,7 +107,7 @@ unsigned long len;
l=(c->Nl+(len<<3))&0xffffffffL;
/* 95-05-24 eay Fixed a bug with the overflow handling, thanks to
* Wei Dai <weidai@eskimo.com> for pointing it out. */
if (l < c->Nl) /* overflow */
if (l < c->Nl) /*%< overflow */
c->Nh++;
c->Nh+=(len>>29);
c->Nl=l;
@ -136,7 +139,7 @@ unsigned long len;
int ew,ec;
c->num+=(int)len;
if ((sc+len) < 4U) /* ugly, add char's to a word */
if ((sc+len) < 4U) /*%< ugly, add char's to a word */
{
l= p[sw];
p_c2l_p(data,l,sc,len);
@ -184,8 +187,8 @@ unsigned long len;
c2l(data,l); *(p++)=l;
c2l(data,l); *(p++)=l;
c2l(data,l); *(p++)=l;
c2l(data,l); *(p++)=l;
}
c2l(data,l); *(p++)=l;
}
#endif
p=c->data;
md5_block(c,p);
@ -195,7 +198,7 @@ unsigned long len;
c->num=sc;
if (sc)
{
sw=sc>>2; /* words to copy */
sw=sc>>2; /*%< words to copy */
#ifdef L_ENDIAN
p[sw]=0;
memcpy(p,data,sc);
@ -367,4 +370,5 @@ unsigned long *l;
}
}
#endif
#endif /* HAVE_MD5 */
#endif /* USE_MD5 */

View File

@ -147,7 +147,8 @@
(a)=ROTATE(l,16L); \
}
#endif
/*
/*%
#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
#define G(x,y,z) (((x) & (z)) | ((y) & (~(z))))
*/
@ -188,3 +189,5 @@
a+=((k)+(t)+I((b),(c),(d))); \
a=ROTATE(a,s); \
a+=b; };
/*! \file */

View File

@ -1,3 +1,6 @@
static const char rcsid[] = "$Header: /proj/cvs/prod/libbind/dst/support.c,v 1.6 2005/10/11 00:10:13 marka Exp $";
/*
* Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
*
@ -31,7 +34,7 @@
#include "port_after.h"
/*
/*%
* dst_s_verify_str()
* Validate that the input string(*str) is at the head of the input
* buffer(**buf). If so, move the buffer head pointer (*buf) to
@ -49,20 +52,20 @@ int
dst_s_verify_str(const char **buf, const char *str)
{
int b, s;
if (*buf == NULL) /* error checks */
if (*buf == NULL) /*%< error checks */
return (0);
if (str == NULL || *str == '\0')
return (1);
b = strlen(*buf); /* get length of strings */
b = strlen(*buf); /*%< get length of strings */
s = strlen(str);
if (s > b || strncmp(*buf, str, s)) /* check if same */
return (0); /* not a match */
(*buf) += s; /* advance pointer */
if (s > b || strncmp(*buf, str, s)) /*%< check if same */
return (0); /*%< not a match */
(*buf) += s; /*%< advance pointer */
return (1);
}
/*
/*%
* dst_s_calculate_bits
* Given a binary number represented in a u_char[], determine
* the number of significant bits used.
@ -86,8 +89,7 @@ dst_s_calculate_bits(const u_char *str, const int max_bits)
return (bits);
}
/*
/*%
* calculates a checksum used in dst for an id.
* takes an array of bytes and a length.
* returns a 16 bit checksum.
@ -100,7 +102,7 @@ dst_s_id_calc(const u_char *key, const int keysize)
int size = keysize;
if (!key || (keysize <= 0))
return (-1);
return (0xffffU);
for (ac = 0; size > 1; size -= 2, kp += 2)
ac += ((*kp) << 8) + *(kp + 1);
@ -112,7 +114,7 @@ dst_s_id_calc(const u_char *key, const int keysize)
return (ac & 0xffff);
}
/*
/*%
* dst_s_dns_key_id() Function to calculate DNSSEC footprint from KEY record
* rdata
* Input:
@ -128,7 +130,7 @@ dst_s_dns_key_id(const u_char *dns_key_rdata, const int rdata_len)
return 0;
/* compute id */
if (dns_key_rdata[3] == KEY_RSA) /* Algorithm RSA */
if (dns_key_rdata[3] == KEY_RSA) /*%< Algorithm RSA */
return dst_s_get_int16((const u_char *)
&dns_key_rdata[rdata_len - 3]);
else if (dns_key_rdata[3] == KEY_HMAC_MD5)
@ -139,7 +141,7 @@ dst_s_dns_key_id(const u_char *dns_key_rdata, const int rdata_len)
return dst_s_id_calc(dns_key_rdata, rdata_len);
}
/*
/*%
* dst_s_get_int16
* This routine extracts a 16 bit integer from a two byte character
* string. The character string is assumed to be in network byte
@ -158,8 +160,7 @@ dst_s_get_int16(const u_char *buf)
return (a);
}
/*
/*%
* dst_s_get_int32
* This routine extracts a 32 bit integer from a four byte character
* string. The character string is assumed to be in network byte
@ -179,8 +180,7 @@ dst_s_get_int32(const u_char *buf)
return (a);
}
/*
/*%
* dst_s_put_int16
* Take a 16 bit integer and store the value in a two byte
* character string. The integer is assumed to be in network
@ -198,8 +198,7 @@ dst_s_put_int16(u_int8_t *buf, const u_int16_t val)
buf[1] = (u_int8_t)(val);
}
/*
/*%
* dst_s_put_int32
* Take a 32 bit integer and store the value in a four byte
* character string. The integer is assumed to be in network
@ -219,13 +218,12 @@ dst_s_put_int32(u_int8_t *buf, const u_int32_t val)
buf[3] = (u_int8_t)(val);
}
/*
/*%
* dst_s_filename_length
*
* This function returns the number of bytes needed to hold the
* filename for a key file. '/', '\' and ':' are not allowed.
* form: K<keyname>+<alg>+<id>.<suffix>
* form: K&lt;keyname&gt;+&lt;alg&gt;+&lt;id&gt;.&lt;suffix&gt;
*
* Returns 0 if the filename would contain either '\', '/' or ':'
*/
@ -251,13 +249,12 @@ dst_s_filename_length(const char *name, const char *suffix)
return (1 + strlen(name) + 6 + strlen(suffix));
}
/*
/*%
* dst_s_build_filename ()
* Builds a key filename from the key name, it's id, and a
* suffix. '\', '/' and ':' are not allowed. fA filename is of the
* form: K<keyname><id>.<suffix>
* form: K<keyname>+<alg>+<id>.<suffix>
* form: K&lt;keyname&gt;&lt;id&gt;.&lt;suffix&gt;
* form: K&lt;keyname&gt;+&lt;alg&gt;+&lt;id&gt;.&lt;suffix&gt;
*
* Returns -1 if the conversion fails:
* if the filename would be too long for space allotted
@ -291,7 +288,7 @@ dst_s_build_filename(char *filename, const char *name, u_int16_t id,
return (0);
}
/*
/*%
* dst_s_fopen ()
* Open a file in the dst_path directory. If perm is specified, the
* file is checked for existence first, and not opened if it exists.
@ -308,19 +305,15 @@ dst_s_fopen(const char *filename, const char *mode, int perm)
{
FILE *fp;
char pathname[PATH_MAX];
size_t plen = sizeof(pathname);
if (strlen(filename) + strlen(dst_path) >= sizeof(pathname))
return (NULL);
if (*dst_path != '\0') {
strcpy(pathname, dst_path);
plen -= strlen(pathname);
}
else
pathname[0] = '\0';
if (plen > strlen(filename))
strncpy(&pathname[PATH_MAX - plen], filename, plen-1);
else
return (NULL);
strcat(pathname, filename);
} else
strcpy(pathname, filename);
fp = fopen(pathname, mode);
if (perm)
@ -345,3 +338,5 @@ dst_s_dump(const int mode, const u_char *data, const int size,
#endif
}
}
/*! \file */

View File

@ -0,0 +1,224 @@
# Copyright (C) 2004, 2007-2009 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 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: Makefile.in,v 1.10 2009/01/28 23:49:09 tbox Exp $
srcdir = .
top_srcdir = ..
HEADERS=fd_setsize.h hesiod.h irp.h irs.h netdb.h netgroup.h res_update.h \
resolv.h
AHEADERS= arpa/inet.h arpa/nameser.h arpa/nameser_compat.h
IHEADERS= isc/assertions.h isc/ctl.h isc/dst.h isc/eventlib.h isc/heap.h \
isc/irpmarshall.h isc/list.h isc/logging.h isc/memcluster.h \
isc/misc.h isc/tree.h isc/platform.h
all:
# Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2001, 2002 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: rules.in,v 1.15 2009/01/22 23:49:23 tbox Exp $
###
### Common Makefile rules for BIND 9.
###
###
### Paths
###
### Note: paths that vary by Makefile MUST NOT be listed
### here, or they won't get expanded correctly.
prefix = /usr/local
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
sbindir = ${exec_prefix}/sbin
includedir = ${prefix}/include/bind
libdir = ${exec_prefix}/lib
sysconfdir = ${prefix}/etc
localstatedir = ${prefix}/var
mandir = ${datarootdir}/man
datarootdir = ${prefix}/share
DESTDIR =
MAKEDEFS= 'DESTDIR=${DESTDIR}'
top_builddir = /boot/home/develop/haiku/haiku/src/kits/network/libbind
abs_top_srcdir = /boot/home/develop/haiku/haiku/src/kits/network/libbind
###
### All
###
### Makefile may define:
### TARGETS
all: subdirs ${TARGETS}
###
### Subdirectories
###
### Makefile may define:
### SUBDIRS
ALL_SUBDIRS = ${SUBDIRS} nulldir
#
# We use a single-colon rule so that additional dependencies of
# subdirectories can be specified after the inclusion of this file.
# The "depend" target is treated the same way.
#
subdirs:
@for i in ${ALL_SUBDIRS}; do \
if [ "$$i" != "nulldir" -a -d $$i ]; then \
echo "making all in `pwd`/$$i"; \
(cd $$i; ${MAKE} ${MAKEDEFS} all) || exit 1; \
fi; \
done
install clean distclean docclean manclean::
@for i in ${ALL_SUBDIRS}; do \
if [ "$$i" != "nulldir" -a -d $$i ]; then \
echo "making $@ in `pwd`/$$i"; \
(cd $$i; ${MAKE} ${MAKEDEFS} $@) || exit 1; \
fi \
done
###
### C Programs
###
### Makefile must define
### CC
### Makefile may define
### CFLAGS
### CINCLUDES
### CDEFINES
### CWARNINGS
### User may define externally
### EXT_CFLAGS
CC = gcc
CFLAGS = -g -O2
STD_CINCLUDES =
STD_CDEFINES =
STD_CWARNINGS = -W -Wall -Wmissing-prototypes -Wcast-qual -Wwrite-strings -Wformat -Wpointer-arith -fno-strict-aliasing
.SUFFIXES:
.SUFFIXES: .c .o
ALWAYS_INCLUDES = -I${top_builddir} -I${abs_top_srcdir}/port/unknown/include
ALWAYS_DEFINES =
ALWAYS_WARNINGS =
ALL_CPPFLAGS = \
${ALWAYS_INCLUDES} ${CINCLUDES} ${STD_CINCLUDES} \
${ALWAYS_DEFINES} ${CDEFINES} ${STD_CDEFINES}
ALL_CFLAGS = ${EXT_CFLAGS} ${CFLAGS} \
${ALL_CPPFLAGS} \
${ALWAYS_WARNINGS} ${STD_CWARNINGS} ${CWARNINGS}
.c.o:
${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c $<
SHELL = /bin/sh
LIBTOOL =
LIBTOOL_MODE_COMPILE = ${LIBTOOL}
LIBTOOL_MODE_INSTALL = ${LIBTOOL}
LIBTOOL_MODE_LINK = ${LIBTOOL}
PURIFY =
MKDEP = ${SHELL} ${top_builddir}/make/mkdep
cleandir: distclean
clean distclean::
rm -f *.o *.lo *.la core *.core .depend
rm -rf .libs
distclean::
rm -f Makefile
depend:
@for i in ${ALL_SUBDIRS}; do \
if [ "$$i" != "nulldir" -a -d $$i ]; then \
echo "making depend in `pwd`/$$i"; \
(cd $$i; ${MAKE} ${MAKEDEFS} $@) || exit 1; \
fi \
done
@if [ X"${SRCS}" != X -a X"${PSRCS}" != X ] ; then \
echo ${MKDEP} ${ALL_CPPFLAGS} ${SRCS}; \
${MKDEP} ${ALL_CPPFLAGS} ${SRCS}; \
echo ${MKDEP} -ap ${ALL_CPPFLAGS} ${PSRCS}; \
${MKDEP} -ap ${ALL_CPPFLAGS} ${PSRCS}; \
${DEPENDEXTRA} \
elif [ X"${SRCS}" != X ] ; then \
echo ${MKDEP} ${ALL_CPPFLAGS} ${SRCS}; \
${MKDEP} ${ALL_CPPFLAGS} ${SRCS}; \
${DEPENDEXTRA} \
elif [ X"${PSRCS}" != X ] ; then \
echo ${MKDEP} ${ALL_CPPFLAGS} ${PSRCS}; \
${MKDEP} -p ${ALL_CPPFLAGS} ${PSRCS}; \
${DEPENDEXTRA} \
fi
FORCE:
###
### Libraries
###
AR = /boot/develop/tools/gnupro/bin/ar
ARFLAGS = cruv
RANLIB = ranlib
###
### Installation
###
INSTALL = /bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
installdirs:
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir} \
${DESTDIR}${includedir}/arpa ${DESTDIR}${includedir}/isc
install:: installdirs
for i in ${HEADERS}; do \
${INSTALL_DATA} ${srcdir}/$$i ${DESTDIR}${includedir}; \
done
for i in ${IHEADERS}; do \
${INSTALL_DATA} ${srcdir}/$$i ${DESTDIR}${includedir}/isc; \
done
for i in ${AHEADERS}; do \
${INSTALL_DATA} ${srcdir}/$$i ${DESTDIR}${includedir}/arpa; \
done

View File

@ -0,0 +1,47 @@
# Copyright (C) 2004, 2007-2009 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 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: Makefile.in,v 1.10 2009/01/28 23:49:09 tbox Exp $
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
HEADERS=fd_setsize.h hesiod.h irp.h irs.h netdb.h netgroup.h res_update.h \
resolv.h
AHEADERS= arpa/inet.h arpa/nameser.h arpa/nameser_compat.h
IHEADERS= isc/assertions.h isc/ctl.h isc/dst.h isc/eventlib.h isc/heap.h \
isc/irpmarshall.h isc/list.h isc/logging.h isc/memcluster.h \
isc/misc.h isc/tree.h isc/platform.h
all:
@BIND9_MAKE_RULES@
installdirs:
$(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir} \
${DESTDIR}${includedir}/arpa ${DESTDIR}${includedir}/isc
install:: installdirs
for i in ${HEADERS}; do \
${INSTALL_DATA} ${srcdir}/$$i ${DESTDIR}${includedir}; \
done
for i in ${IHEADERS}; do \
${INSTALL_DATA} ${srcdir}/$$i ${DESTDIR}${includedir}/isc; \
done
for i in ${AHEADERS}; do \
${INSTALL_DATA} ${srcdir}/$$i ${DESTDIR}${includedir}/arpa; \
done

View File

@ -1,7 +1,7 @@
/*
* ++Copyright++ 1995
* ++Copyright++ 1983, 1993
* -
* Copyright (c) 1995
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -53,21 +53,74 @@
* --Copyright--
*/
const char *_res_resultcodes[] = {
"NOERROR",
"FORMERR",
"SERVFAIL",
"NXDOMAIN",
"NOTIMP",
"REFUSED",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"NOCHANGE",
};
/*%
* @(#)inet.h 8.1 (Berkeley) 6/2/93
* $Id: inet.h,v 1.3 2005/04/27 04:56:16 sra Exp $
*/
#ifndef _INET_H_
#define _INET_H_
/* External definitions for functions in inet(3) */
#include <sys/param.h>
#if (!defined(BSD)) || (BSD < 199306)
# include <sys/bitypes.h>
#else
# include <sys/types.h>
#endif
#include <sys/cdefs.h>
#define inet_addr __inet_addr
#define inet_aton __inet_aton
#define inet_lnaof __inet_lnaof
#define inet_makeaddr __inet_makeaddr
#define inet_neta __inet_neta
#define inet_netof __inet_netof
#define inet_network __inet_network
#define inet_net_ntop __inet_net_ntop
#define inet_net_pton __inet_net_pton
#define inet_cidr_ntop __inet_cidr_ntop
#define inet_cidr_pton __inet_cidr_pton
#define inet_ntoa __inet_ntoa
#define inet_pton __inet_pton
#define inet_ntop __inet_ntop
#define inet_nsap_addr __inet_nsap_addr
#define inet_nsap_ntoa __inet_nsap_ntoa
__BEGIN_DECLS
unsigned long inet_addr __P((const char *));
int inet_aton __P((const char *, struct in_addr *));
unsigned long inet_lnaof __P((struct in_addr));
struct in_addr inet_makeaddr __P((u_long , u_long));
char * inet_neta __P((u_long, char *, size_t));
unsigned long inet_netof __P((struct in_addr));
unsigned long inet_network __P((const char *));
char *inet_net_ntop __P((int, const void *, int, char *, size_t));
int inet_net_pton __P((int, const char *, void *, size_t));
char *inet_cidr_ntop __P((int, const void *, int, char *, size_t));
int inet_cidr_pton __P((int, const char *, void *, int *));
/*const*/ char *inet_ntoa __P((struct in_addr));
int inet_pton __P((int, const char *, void *));
const char *inet_ntop __P((int, const void *, char *, size_t));
u_int inet_nsap_addr __P((const char *, u_char *, int));
char *inet_nsap_ntoa __P((int, const u_char *, char *));
__END_DECLS
#if defined(__hpux) && defined(_XOPEN_SOURCE_EXTENDED)
/*
* Macros for number representation conversion.
*
* netinet/in.h is another location for these macros
*/
#ifndef ntohl
#define ntohl(x) (x)
#define ntohs(x) (x)
#define htonl(x) (x)
#define htons(x) (x)
#endif
#endif
#endif /* !_INET_H_ */
/*! \file */

View File

@ -0,0 +1,675 @@
/*
* 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 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
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* $Id: nameser.h,v 1.16 2009/03/03 01:52:48 each Exp $
*/
#ifndef _ARPA_NAMESER_H_
#define _ARPA_NAMESER_H_
/*! \file */
#define BIND_4_COMPAT
#include <sys/param.h>
#if (!defined(BSD)) || (BSD < 199306)
# include <sys/bitypes.h>
#else
# include <sys/types.h>
#endif
#include <sys/cdefs.h>
/*%
* Revision information. This is the release date in YYYYMMDD format.
* It can change every day so the right thing to do with it is use it
* in preprocessor commands such as "#if (__NAMESER > 19931104)". Do not
* compare for equality; rather, use it to determine whether your libbind.a
* contains a new enough lib/nameser/ to support the feature you need.
*/
#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 (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 */
#define NS_INT32SZ 4 /*%< #/bytes of data in a u_int32_t */
#define NS_INT16SZ 2 /*%< #/bytes of data in a u_int16_t */
#define NS_INT8SZ 1 /*%< #/bytes of data in a u_int8_t */
#define NS_INADDRSZ 4 /*%< IPv4 T_A */
#define NS_IN6ADDRSZ 16 /*%< IPv6 T_AAAA */
#define NS_CMPRSFLGS 0xc0 /*%< Flag bits indicating name compression. */
#define NS_DEFAULTPORT 53 /*%< For both TCP and UDP. */
/*
* These can be expanded with synonyms, just keep ns_parse.c:ns_parserecord()
* in synch with it.
*/
typedef enum __ns_sect {
ns_s_qd = 0, /*%< Query: Question. */
ns_s_zn = 0, /*%< Update: Zone. */
ns_s_an = 1, /*%< Query: Answer. */
ns_s_pr = 1, /*%< Update: Prerequisites. */
ns_s_ns = 2, /*%< Query: Name servers. */
ns_s_ud = 2, /*%< Update: Update. */
ns_s_ar = 3, /*%< Query|Update: Additional records. */
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
* leading _'s on the member names. Use the accessor functions, not the _'s.
*/
typedef struct __ns_msg {
const u_char *_msg, *_eom;
u_int16_t _id, _flags, _counts[ns_s_max];
const u_char *_sections[ns_s_max];
ns_sect _sect;
int _rrnum;
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[];
/* Accessor macros - this is part of the public interface. */
#define ns_msg_id(handle) ((handle)._id + 0)
#define ns_msg_base(handle) ((handle)._msg + 0)
#define ns_msg_end(handle) ((handle)._eom + 0)
#define ns_msg_size(handle) ((handle)._eom - (handle)._msg)
#define ns_msg_count(handle, section) ((handle)._counts[section] + 0)
/*%
* This is a parsed record. It is caller allocated and has no dynamic data.
*/
typedef struct __ns_rr {
char name[NS_MAXDNAME];
u_int16_t type;
u_int16_t rr_class;
u_int32_t ttl;
u_int16_t rdlength;
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)
#define ns_rr_rdlen(rr) ((rr).rdlength + 0)
#define ns_rr_rdata(rr) ((rr).rdata + 0)
/*%
* These don't have to be in the same order as in the packet flags word,
* and they can even overlap in some cases, but they will need to be kept
* in synch with ns_parse.c:ns_flagdata[].
*/
typedef enum __ns_flag {
ns_f_qr, /*%< Question/Response. */
ns_f_opcode, /*%< Operation code. */
ns_f_aa, /*%< Authoritative Answer. */
ns_f_tc, /*%< Truncation occurred. */
ns_f_rd, /*%< Recursion Desired. */
ns_f_ra, /*%< Recursion Available. */
ns_f_z, /*%< MBZ. */
ns_f_ad, /*%< Authentic Data (DNSSEC). */
ns_f_cd, /*%< Checking Disabled (DNSSEC). */
ns_f_rcode, /*%< Response code. */
ns_f_max
} ns_flag;
/*%
* Currently defined opcodes.
*/
typedef enum __ns_opcode {
ns_o_query = 0, /*%< Standard query. */
ns_o_iquery = 1, /*%< Inverse query (deprecated/unsupported). */
ns_o_status = 2, /*%< Name server status query (unsupported). */
/* Opcode 3 is undefined/reserved. */
ns_o_notify = 4, /*%< Zone change notification. */
ns_o_update = 5, /*%< Zone update message. */
ns_o_max = 6
} ns_opcode;
/*%
* Currently defined response codes.
*/
typedef enum __ns_rcode {
ns_r_noerror = 0, /*%< No error occurred. */
ns_r_formerr = 1, /*%< Format error. */
ns_r_servfail = 2, /*%< Server failure. */
ns_r_nxdomain = 3, /*%< Name error. */
ns_r_notimpl = 4, /*%< Unimplemented. */
ns_r_refused = 5, /*%< Operation refused. */
/* these are for BIND_UPDATE */
ns_r_yxdomain = 6, /*%< Name exists */
ns_r_yxrrset = 7, /*%< RRset exists */
ns_r_nxrrset = 8, /*%< RRset does not exist */
ns_r_notauth = 9, /*%< Not authoritative for zone */
ns_r_notzone = 10, /*%< Zone of record different from zone section */
ns_r_max = 11,
/* The following are EDNS extended rcodes */
ns_r_badvers = 16,
/* The following are TSIG errors */
ns_r_badsig = 16,
ns_r_badkey = 17,
ns_r_badtime = 18
} ns_rcode;
/* BIND_UPDATE */
typedef enum __ns_update_operation {
ns_uop_delete = 0,
ns_uop_add = 1,
ns_uop_max = 2
} 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;
};
typedef struct ns_tsig_key ns_tsig_key;
/*%
* This structure is used for TSIG authenticated TCP messages
*/
struct ns_tcp_tsig_state {
int counter;
struct dst_key *key;
void *ctx;
unsigned char sig[NS_PACKETSZ];
int siglen;
};
typedef struct ns_tcp_tsig_state ns_tcp_tsig_state;
#define NS_TSIG_FUDGE 300
#define NS_TSIG_TCP_COUNT 100
#define NS_TSIG_ALG_HMAC_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
#define NS_TSIG_ERROR_NO_TSIG -10
#define NS_TSIG_ERROR_NO_SPACE -11
#define NS_TSIG_ERROR_FORMERR -12
/*%
* Currently defined type values for resources and queries.
*/
typedef enum __ns_type {
ns_t_invalid = 0, /*%< Cookie. */
ns_t_a = 1, /*%< Host address. */
ns_t_ns = 2, /*%< Authoritative server. */
ns_t_md = 3, /*%< Mail destination. */
ns_t_mf = 4, /*%< Mail forwarder. */
ns_t_cname = 5, /*%< Canonical name. */
ns_t_soa = 6, /*%< Start of authority zone. */
ns_t_mb = 7, /*%< Mailbox domain name. */
ns_t_mg = 8, /*%< Mail group member. */
ns_t_mr = 9, /*%< Mail rename name. */
ns_t_null = 10, /*%< Null resource record. */
ns_t_wks = 11, /*%< Well known service. */
ns_t_ptr = 12, /*%< Domain name pointer. */
ns_t_hinfo = 13, /*%< Host information. */
ns_t_minfo = 14, /*%< Mailbox information. */
ns_t_mx = 15, /*%< Mail routing information. */
ns_t_txt = 16, /*%< Text strings. */
ns_t_rp = 17, /*%< Responsible person. */
ns_t_afsdb = 18, /*%< AFS cell database. */
ns_t_x25 = 19, /*%< X_25 calling address. */
ns_t_isdn = 20, /*%< ISDN calling address. */
ns_t_rt = 21, /*%< Router. */
ns_t_nsap = 22, /*%< NSAP address. */
ns_t_nsap_ptr = 23, /*%< Reverse NSAP lookup (deprecated). */
ns_t_sig = 24, /*%< Security signature. */
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, /*%< IPv6 Address. */
ns_t_loc = 29, /*%< Location Information. */
ns_t_nxt = 30, /*%< Next domain (security). */
ns_t_eid = 31, /*%< Endpoint identifier. */
ns_t_nimloc = 32, /*%< Nimrod Locator. */
ns_t_srv = 33, /*%< Server Selection. */
ns_t_atma = 34, /*%< ATM Address */
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 (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. */
ns_t_axfr = 252, /*%< Transfer zone of authority. */
ns_t_mailb = 253, /*%< Transfer mailbox records. */
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;
/* Exclusively a QTYPE? (not also an RTYPE) */
#define ns_t_qt_p(t) (ns_t_xfr_p(t) || (t) == ns_t_any || \
(t) == ns_t_mailb || (t) == ns_t_maila)
/* Some kind of meta-RR? (not a QTYPE, but also not an RTYPE) */
#define ns_t_mrr_p(t) ((t) == ns_t_tsig || (t) == ns_t_opt)
/* Exclusively an RTYPE? (not also a QTYPE or a meta-RR) */
#define ns_t_rr_p(t) (!ns_t_qt_p(t) && !ns_t_mrr_p(t))
#define ns_t_udp_p(t) ((t) != ns_t_axfr && (t) != ns_t_zxfr)
#define ns_t_xfr_p(t) ((t) == ns_t_axfr || (t) == ns_t_ixfr || \
(t) == ns_t_zxfr)
/*%
* Values for class field
*/
typedef enum __ns_class {
ns_c_invalid = 0, /*%< Cookie. */
ns_c_in = 1, /*%< Internet. */
ns_c_2 = 2, /*%< unallocated/unsupported. */
ns_c_chaos = 3, /*%< MIT Chaos-net. */
ns_c_hs = 4, /*%< MIT Hesiod. */
/* Query class values which do not appear in resource records */
ns_c_none = 254, /*%< for prereq. sections in update requests */
ns_c_any = 255, /*%< Wildcard match. */
ns_c_max = 65536
} ns_class;
/* DNSSEC constants. */
typedef enum __ns_key_types {
ns_kt_rsa = 1, /*%< key type RSA/MD5 */
ns_kt_dh = 2, /*%< Diffie Hellman */
ns_kt_dsa = 3, /*%< Digital Signature Standard (MANDATORY) */
ns_kt_private = 254 /*%< Private key type starts with OID */
} ns_key_types;
typedef enum __ns_cert_types {
cert_t_pkix = 1, /*%< PKIX (X.509v3) */
cert_t_spki = 2, /*%< SPKI */
cert_t_pgp = 3, /*%< PGP */
cert_t_url = 253, /*%< URL private type */
cert_t_oid = 254 /*%< OID private type */
} ns_cert_types;
/* Flags field of the KEY RR rdata. */
#define NS_KEY_TYPEMASK 0xC000 /*%< Mask for "type" bits */
#define NS_KEY_TYPE_AUTH_CONF 0x0000 /*%< Key usable for both */
#define NS_KEY_TYPE_CONF_ONLY 0x8000 /*%< Key usable for confidentiality */
#define NS_KEY_TYPE_AUTH_ONLY 0x4000 /*%< Key usable for authentication */
#define NS_KEY_TYPE_NO_KEY 0xC000 /*%< No key usable for either; no key */
/* The type bits can also be interpreted independently, as single bits: */
#define NS_KEY_NO_AUTH 0x8000 /*%< Key unusable for authentication */
#define NS_KEY_NO_CONF 0x4000 /*%< Key unusable for confidentiality */
#define NS_KEY_RESERVED2 0x2000 /* Security is *mandatory* if bit=0 */
#define NS_KEY_EXTENDED_FLAGS 0x1000 /*%< reserved - must be zero */
#define NS_KEY_RESERVED4 0x0800 /*%< reserved - must be zero */
#define NS_KEY_RESERVED5 0x0400 /*%< reserved - must be zero */
#define NS_KEY_NAME_TYPE 0x0300 /*%< these bits determine the type */
#define NS_KEY_NAME_USER 0x0000 /*%< key is assoc. with user */
#define NS_KEY_NAME_ENTITY 0x0200 /*%< key is assoc. with entity eg host */
#define NS_KEY_NAME_ZONE 0x0100 /*%< key is zone key */
#define NS_KEY_NAME_RESERVED 0x0300 /*%< reserved meaning */
#define NS_KEY_RESERVED8 0x0080 /*%< reserved - must be zero */
#define NS_KEY_RESERVED9 0x0040 /*%< reserved - must be zero */
#define NS_KEY_RESERVED10 0x0020 /*%< reserved - must be zero */
#define NS_KEY_RESERVED11 0x0010 /*%< reserved - must be zero */
#define NS_KEY_SIGNATORYMASK 0x000F /*%< key can sign RR's of same name */
#define NS_KEY_RESERVED_BITMASK ( NS_KEY_RESERVED2 | \
NS_KEY_RESERVED4 | \
NS_KEY_RESERVED5 | \
NS_KEY_RESERVED8 | \
NS_KEY_RESERVED9 | \
NS_KEY_RESERVED10 | \
NS_KEY_RESERVED11 )
#define NS_KEY_RESERVED_BITMASK2 0xFFFF /*%< no bits defined here */
/* The Algorithm field of the KEY and SIG RR's is an integer, {1..254} */
#define NS_ALG_MD5RSA 1 /*%< MD5 with RSA */
#define NS_ALG_DH 2 /*%< Diffie Hellman KEY */
#define NS_ALG_DSA 3 /*%< DSA KEY */
#define NS_ALG_DSS NS_ALG_DSA
#define NS_ALG_EXPIRE_ONLY 253 /*%< No alg, no security */
#define NS_ALG_PRIVATE_OID 254 /*%< Key begins with OID giving alg */
/* Protocol values */
/* value 0 is reserved */
#define NS_KEY_PROT_TLS 1
#define NS_KEY_PROT_EMAIL 2
#define NS_KEY_PROT_DNSSEC 3
#define NS_KEY_PROT_IPSEC 4
#define NS_KEY_PROT_ANY 255
/* Signatures */
#define NS_MD5RSA_MIN_BITS 512 /*%< Size of a mod or exp in bits */
#define NS_MD5RSA_MAX_BITS 4096
/* Total of binary mod and exp */
#define NS_MD5RSA_MAX_BYTES ((NS_MD5RSA_MAX_BITS+7/8)*2+3)
/* Max length of text sig block */
#define NS_MD5RSA_MAX_BASE64 (((NS_MD5RSA_MAX_BYTES+2)/3)*4)
#define NS_MD5RSA_MIN_SIZE ((NS_MD5RSA_MIN_BITS+7)/8)
#define NS_MD5RSA_MAX_SIZE ((NS_MD5RSA_MAX_BITS+7)/8)
#define NS_DSA_SIG_SIZE 41
#define NS_DSA_MIN_SIZE 213
#define NS_DSA_MAX_BYTES 405
/* Offsets into SIG record rdata to find various values */
#define NS_SIG_TYPE 0 /*%< Type flags */
#define NS_SIG_ALG 2 /*%< Algorithm */
#define NS_SIG_LABELS 3 /*%< How many labels in name */
#define NS_SIG_OTTL 4 /*%< Original TTL */
#define NS_SIG_EXPIR 8 /*%< Expiration time */
#define NS_SIG_SIGNED 12 /*%< Signature time */
#define NS_SIG_FOOT 16 /*%< Key footprint */
#define NS_SIG_SIGNER 18 /*%< Domain name of who signed it */
/* How RR types are represented as bit-flags in NXT records */
#define NS_NXT_BITS 8
#define NS_NXT_BIT_SET( n,p) (p[(n)/NS_NXT_BITS] |= (0x80>>((n)%NS_NXT_BITS)))
#define NS_NXT_BIT_CLEAR(n,p) (p[(n)/NS_NXT_BITS] &= ~(0x80>>((n)%NS_NXT_BITS)))
#define NS_NXT_BIT_ISSET(n,p) (p[(n)/NS_NXT_BITS] & (0x80>>((n)%NS_NXT_BITS)))
#define NS_NXT_MAX 127
/*%
* EDNS0 extended flags and option codes, host order.
*/
#define NS_OPT_DNSSEC_OK 0x8000U
#define NS_OPT_NSID 3
/*%
* Inline versions of get/put short/long. Pointer is advanced.
*/
#define NS_GET16(s, cp) do { \
register const u_char *t_cp = (const u_char *)(cp); \
(s) = ((u_int16_t)t_cp[0] << 8) \
| ((u_int16_t)t_cp[1]) \
; \
(cp) += NS_INT16SZ; \
} while (0)
#define NS_GET32(l, cp) do { \
register const u_char *t_cp = (const u_char *)(cp); \
(l) = ((u_int32_t)t_cp[0] << 24) \
| ((u_int32_t)t_cp[1] << 16) \
| ((u_int32_t)t_cp[2] << 8) \
| ((u_int32_t)t_cp[3]) \
; \
(cp) += NS_INT32SZ; \
} while (0)
#define NS_PUT16(s, cp) do { \
register u_int16_t t_s = (u_int16_t)(s); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_s >> 8; \
*t_cp = t_s; \
(cp) += NS_INT16SZ; \
} while (0)
#define NS_PUT32(l, cp) do { \
register u_int32_t t_l = (u_int32_t)(l); \
register u_char *t_cp = (u_char *)(cp); \
*t_cp++ = t_l >> 24; \
*t_cp++ = t_l >> 16; \
*t_cp++ = t_l >> 8; \
*t_cp = t_l; \
(cp) += NS_INT32SZ; \
} while (0)
/*%
* ANSI C identifier hiding for bind's lib/nameser.
*/
#define ns_msg_getflag __ns_msg_getflag
#define ns_get16 __ns_get16
#define ns_get32 __ns_get32
#define ns_put16 __ns_put16
#define ns_put32 __ns_put32
#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
#define ns_parse_ttl __ns_parse_ttl
#define ns_datetosecs __ns_datetosecs
#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
#define ns_sign_tcp2 __ns_sign_tcp2
#define ns_sign_tcp_init __ns_sign_tcp_init
#define ns_find_tsig __ns_find_tsig
#define ns_verify __ns_verify
#define ns_verify_tcp __ns_verify_tcp
#define ns_verify_tcp_init __ns_verify_tcp_init
#define ns_samedomain __ns_samedomain
#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));
u_int ns_get16 __P((const u_char *));
u_long ns_get32 __P((const u_char *));
void ns_put16 __P((u_int, u_char *));
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 *,
ns_class, ns_type, u_long, const u_char *,
size_t, const char *, const char *,
char *, size_t));
int ns_format_ttl __P((u_long, char *, size_t));
int ns_parse_ttl __P((const char *, u_long *));
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 *,
const u_char *, char *, size_t));
int ns_name_compress __P((const char *, u_char *, size_t,
const u_char **, const u_char **));
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 *,
const u_char *, int, u_char *, int *, time_t,
u_char **, u_char **));
int ns_sign_tcp __P((u_char *, int *, int, int,
ns_tcp_tsig_state *, int));
int ns_sign_tcp2 __P((u_char *, int *, int, int,
ns_tcp_tsig_state *, int,
u_char **, u_char **));
int ns_sign_tcp_init __P((void *, const u_char *, int,
ns_tcp_tsig_state *));
u_char *ns_find_tsig __P((u_char *, u_char *));
int ns_verify __P((u_char *, int *, void *,
const u_char *, int, u_char *, int *,
time_t *, int));
int ns_verify_tcp __P((u_char *, int *, ns_tcp_tsig_state *, int));
int ns_verify_tcp_init __P((void *, const u_char *, int,
ns_tcp_tsig_state *));
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
#include <arpa/nameser_compat.h>
#endif
#endif /* !_ARPA_NAMESER_H_ */
/*! \file */

View File

@ -0,0 +1,232 @@
/* Copyright (c) 1983, 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 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
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*%
* from nameser.h 8.1 (Berkeley) 6/2/93
* $Id: nameser_compat.h,v 1.8 2006/05/19 02:33:40 marka Exp $
*/
#ifndef _ARPA_NAMESER_COMPAT_
#define _ARPA_NAMESER_COMPAT_
#define __BIND 19950621 /*%< (DEAD) interface version stamp. */
#ifndef BYTE_ORDER
#if (BSD >= 199103)
# include <machine/endian.h>
#else
#ifdef __linux
# include <endian.h>
#else
#define LITTLE_ENDIAN 1234 /*%< least-significant byte first (vax, pc) */
#define BIG_ENDIAN 4321 /*%< most-significant byte first (IBM, net) */
#define PDP_ENDIAN 3412 /*%< LSB first in word, MSW first in long (pdp) */
#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
defined(__i386__) || defined(__i386) || defined(__amd64__) || \
defined(__x86_64__) || defined(MIPSEL) || defined(_MIPSEL) || \
defined(BIT_ZERO_ON_RIGHT) || defined(__alpha__) || defined(__alpha) || \
(defined(__Lynx__) && defined(__x86__))
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
defined(apollo) || defined(__convex__) || defined(_CRAY) || \
defined(__hppa) || defined(__hp9000) || \
defined(__hp9000s300) || defined(__hp9000s700) || \
defined(__hp3000s900) || defined(__hpux) || defined(MPE) || \
defined (BIT_ZERO_ON_LEFT) || defined(m68k) || defined(__sparc) || \
(defined(__Lynx__) && \
(defined(__68k__) || defined(__sparc__) || defined(__powerpc__)))
#define BYTE_ORDER BIG_ENDIAN
#endif
#endif /* __linux */
#endif /* BSD */
#endif /* BYTE_ORDER */
#if !defined(BYTE_ORDER) || \
(BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
BYTE_ORDER != PDP_ENDIAN)
/* you must determine what the correct bit order is for
* your compiler - the next line is an intentional error
* which will force your compiles to bomb until you fix
* the above macros.
*/
error "Undefined or invalid BYTE_ORDER";
#endif
/*%
* Structure for query header. The order of the fields is machine- and
* compiler-dependent, depending on the byte/bit order and the layout
* of bit fields. We use bit fields only in int variables, as this
* is all ANSI requires. This requires a somewhat confusing rearrangement.
*/
typedef struct {
unsigned id :16; /*%< query identification number */
#if BYTE_ORDER == BIG_ENDIAN
/* fields in third byte */
unsigned qr: 1; /*%< response flag */
unsigned opcode: 4; /*%< purpose of message */
unsigned aa: 1; /*%< authoritive answer */
unsigned tc: 1; /*%< truncated message */
unsigned rd: 1; /*%< recursion desired */
/* fields in fourth byte */
unsigned ra: 1; /*%< recursion available */
unsigned unused :1; /*%< unused bits (MBZ as of 4.9.3a3) */
unsigned ad: 1; /*%< authentic data from named */
unsigned cd: 1; /*%< checking disabled by resolver */
unsigned rcode :4; /*%< response code */
#endif
#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
/* fields in third byte */
unsigned rd :1; /*%< recursion desired */
unsigned tc :1; /*%< truncated message */
unsigned aa :1; /*%< authoritive answer */
unsigned opcode :4; /*%< purpose of message */
unsigned qr :1; /*%< response flag */
/* fields in fourth byte */
unsigned rcode :4; /*%< response code */
unsigned cd: 1; /*%< checking disabled by resolver */
unsigned ad: 1; /*%< authentic data from named */
unsigned unused :1; /*%< unused bits (MBZ as of 4.9.3a3) */
unsigned ra :1; /*%< recursion available */
#endif
/* remaining bytes */
unsigned qdcount :16; /*%< number of question entries */
unsigned ancount :16; /*%< number of answer entries */
unsigned nscount :16; /*%< number of authority entries */
unsigned arcount :16; /*%< number of resource entries */
} HEADER;
#define PACKETSZ NS_PACKETSZ
#define MAXDNAME NS_MAXDNAME
#define MAXCDNAME NS_MAXCDNAME
#define MAXLABEL NS_MAXLABEL
#define HFIXEDSZ NS_HFIXEDSZ
#define QFIXEDSZ NS_QFIXEDSZ
#define RRFIXEDSZ NS_RRFIXEDSZ
#define INT32SZ NS_INT32SZ
#define INT16SZ NS_INT16SZ
#define INT8SZ NS_INT8SZ
#define INADDRSZ NS_INADDRSZ
#define IN6ADDRSZ NS_IN6ADDRSZ
#define INDIR_MASK NS_CMPRSFLGS
#define NAMESERVER_PORT NS_DEFAULTPORT
#define S_ZONE ns_s_zn
#define S_PREREQ ns_s_pr
#define S_UPDATE ns_s_ud
#define S_ADDT ns_s_ar
#define QUERY ns_o_query
#define IQUERY ns_o_iquery
#define STATUS ns_o_status
#define NS_NOTIFY_OP ns_o_notify
#define NS_UPDATE_OP ns_o_update
#define NOERROR ns_r_noerror
#define FORMERR ns_r_formerr
#define SERVFAIL ns_r_servfail
#define NXDOMAIN ns_r_nxdomain
#define NOTIMP ns_r_notimpl
#define REFUSED ns_r_refused
#define YXDOMAIN ns_r_yxdomain
#define YXRRSET ns_r_yxrrset
#define NXRRSET ns_r_nxrrset
#define NOTAUTH ns_r_notauth
#define NOTZONE ns_r_notzone
/*#define BADSIG ns_r_badsig*/
/*#define BADKEY ns_r_badkey*/
/*#define BADTIME ns_r_badtime*/
#define DELETE ns_uop_delete
#define ADD ns_uop_add
#define T_A ns_t_a
#define T_NS ns_t_ns
#define T_MD ns_t_md
#define T_MF ns_t_mf
#define T_CNAME ns_t_cname
#define T_SOA ns_t_soa
#define T_MB ns_t_mb
#define T_MG ns_t_mg
#define T_MR ns_t_mr
#define T_NULL ns_t_null
#define T_WKS ns_t_wks
#define T_PTR ns_t_ptr
#define T_HINFO ns_t_hinfo
#define T_MINFO ns_t_minfo
#define T_MX ns_t_mx
#define T_TXT ns_t_txt
#define T_RP ns_t_rp
#define T_AFSDB ns_t_afsdb
#define T_X25 ns_t_x25
#define T_ISDN ns_t_isdn
#define T_RT ns_t_rt
#define T_NSAP ns_t_nsap
#define T_NSAP_PTR ns_t_nsap_ptr
#define T_SIG ns_t_sig
#define T_KEY ns_t_key
#define T_PX ns_t_px
#define T_GPOS ns_t_gpos
#define T_AAAA ns_t_aaaa
#define T_LOC ns_t_loc
#define T_NXT ns_t_nxt
#define T_EID ns_t_eid
#define T_NIMLOC ns_t_nimloc
#define T_SRV ns_t_srv
#define T_ATMA ns_t_atma
#define T_NAPTR ns_t_naptr
#define T_A6 ns_t_a6
#define T_TSIG ns_t_tsig
#define T_IXFR ns_t_ixfr
#define T_AXFR ns_t_axfr
#define T_MAILB ns_t_mailb
#define T_MAILA ns_t_maila
#define T_ANY ns_t_any
#define C_IN ns_c_in
#define C_CHAOS ns_c_chaos
#define C_HS ns_c_hs
/* BIND_UPDATE */
#define C_NONE ns_c_none
#define C_ANY ns_c_any
#define GETSHORT NS_GET16
#define GETLONG NS_GET32
#define PUTSHORT NS_PUT16
#define PUTLONG NS_PUT32
#endif /* _ARPA_NAMESER_COMPAT_ */
/*! \file */

View File

@ -0,0 +1,514 @@
/*
* 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 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
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*%
* @(#)resolv.h 8.1 (Berkeley) 6/2/93
* $Id: resolv.h,v 1.30 2009/03/03 01:52:48 each Exp $
*/
#ifndef _RESOLV_H_
#define _RESOLV_H_
#include <sys/param.h>
#if (!defined(BSD)) || (BSD < 199306)
# include <sys/bitypes.h>
#else
# include <sys/types.h>
#endif
#include <sys/cdefs.h>
#include <sys/socket.h>
#include <stdio.h>
#include <arpa/nameser.h>
/*%
* Revision information. This is the release date in YYYYMMDD format.
* It can change every day so the right thing to do with it is use it
* in preprocessor commands such as "#if (__RES > 19931104)". Do not
* compare for equality; rather, use it to determine whether your resolver
* is new enough to contain a certain feature.
*/
#define __RES 20090302
/*%
* This used to be defined in res_query.c, now it's in herror.c.
* [XXX no it's not. It's in irs/irs_data.c]
* It was
* never extern'd by any *.h file before it was placed here. For thread
* aware programs, the last h_errno value set is stored in res->h_errno.
*
* XXX: There doesn't seem to be a good reason for exposing RES_SET_H_ERRNO
* (and __h_errno_set) to the public via <resolv.h>.
* XXX: __h_errno_set is really part of IRS, not part of the resolver.
* If somebody wants to build and use a resolver that doesn't use IRS,
* what do they do? Perhaps something like
* #ifdef WANT_IRS
* # define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x)
* #else
* # define RES_SET_H_ERRNO(r,x) (h_errno = (r)->res_h_errno = (x))
* #endif
*/
#define RES_SET_H_ERRNO(r,x) __h_errno_set(r,x)
struct __res_state; /*%< forward */
__BEGIN_DECLS
void __h_errno_set(struct __res_state *res, int err);
__END_DECLS
/*%
* Resolver configuration file.
* Normally not present, but may contain the address of the
* initial name server(s) to query and the domain search list.
*/
#ifndef _PATH_RESCONF
#define _PATH_RESCONF "/etc/resolv.conf"
#endif
typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
res_sendhookact;
#ifndef __PMT
#if defined(__STDC__) || defined(__cplusplus)
#define __PMT(args) args
#else
#define __PMT(args) ()
#endif
#endif
typedef res_sendhookact (*res_send_qhook)__PMT((struct sockaddr * const *,
const u_char **, int *,
u_char *, int, int *));
typedef res_sendhookact (*res_send_rhook)__PMT((const struct sockaddr *,
const u_char *, int, u_char *,
int, int *));
struct res_sym {
int number; /*%< Identifying number, like T_MX */
const char * name; /*%< Its symbolic name, like "MX" */
const char * humanname; /*%< Its fun name, like "mail exchanger" */
};
/*%
* Global defines and variables for resolver stub.
*/
#define MAXNS 3 /*%< max # name servers we'll track */
#define MAXDFLSRCH 3 /*%< # default domain levels to try */
#define MAXDNSRCH 6 /*%< max # domains in search path */
#define LOCALDOMAINPARTS 2 /*%< min levels in name that is "local" */
#define RES_TIMEOUT 5 /*%< min. seconds between retries */
#define MAXRESOLVSORT 10 /*%< number of net to sort on */
#define RES_MAXNDOTS 15 /*%< should reflect bit field size */
#define RES_MAXRETRANS 30 /*%< only for resolv.conf/RES_OPTIONS */
#define RES_MAXRETRY 5 /*%< only for resolv.conf/RES_OPTIONS */
#define RES_DFLRETRY 2 /*%< Default #/tries. */
#define RES_MAXTIME 65535 /*%< Infinity, in milliseconds. */
struct __res_state_ext;
struct __res_state {
int retrans; /*%< retransmission time interval */
int retry; /*%< number of times to retransmit */
#ifdef sun
u_int options; /*%< option flags - see below. */
#else
u_long options; /*%< option flags - see below. */
#endif
int nscount; /*%< number of name servers */
struct sockaddr_in
nsaddr_list[MAXNS]; /*%< address of name server */
#define nsaddr nsaddr_list[0] /*%< for backward compatibility */
u_short id; /*%< current message id */
char *dnsrch[MAXDNSRCH+1]; /*%< components of domain to search */
char defdname[256]; /*%< default domain (deprecated) */
#ifdef sun
u_int pfcode; /*%< RES_PRF_ flags - see below. */
#else
u_long pfcode; /*%< RES_PRF_ flags - see below. */
#endif
unsigned ndots:4; /*%< threshold for initial abs. query */
unsigned nsort:4; /*%< number of elements in sort_list[] */
char unused[3];
struct {
struct in_addr addr;
u_int32_t mask;
} sort_list[MAXRESOLVSORT];
res_send_qhook qhook; /*%< query hook */
res_send_rhook rhook; /*%< response hook */
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[56 - 4*sizeof (int) - 2*sizeof (void *)];
struct {
u_int16_t nscount;
u_int16_t nstimes[MAXNS]; /*%< ms. */
int nssocks[MAXNS];
struct __res_state_ext *ext; /*%< extention for IPv6 */
} _ext;
} _u;
};
typedef struct __res_state *res_state;
union res_sockaddr_union {
struct sockaddr_in sin;
#ifdef IN6ADDR_ANY_INIT
struct sockaddr_in6 sin6;
#endif
#ifdef ISC_ALIGN64
int64_t __align64; /*%< 64bit alignment */
#else
int32_t __align32; /*%< 32bit alignment */
#endif
char __space[128]; /*%< max size */
};
/*%
* Resolver flags (used to be discrete per-module statics ints).
*/
#define RES_F_VC 0x00000001 /*%< socket is TCP */
#define RES_F_CONN 0x00000002 /*%< socket is connected */
#define RES_F_EDNS0ERR 0x00000004 /*%< EDNS0 caused errors */
#define RES_F__UNUSED 0x00000008 /*%< (unused) */
#define RES_F_LASTMASK 0x000000F0 /*%< ordinal server of last res_nsend */
#define RES_F_LASTSHIFT 4 /*%< bit position of LASTMASK "flag" */
#define RES_GETLAST(res) (((res)._flags & RES_F_LASTMASK) >> RES_F_LASTSHIFT)
/* res_findzonecut2() options */
#define RES_EXHAUSTIVE 0x00000001 /*%< always do all queries */
#define RES_IPV4ONLY 0x00000002 /*%< IPv4 only */
#define RES_IPV6ONLY 0x00000004 /*%< IPv6 only */
/*%
* Resolver options (keep these in synch with res_debug.c, please)
*/
#define RES_INIT 0x00000001 /*%< address initialized */
#define RES_DEBUG 0x00000002 /*%< print debug messages */
#define RES_AAONLY 0x00000004 /*%< authoritative answers only (!IMPL)*/
#define RES_USEVC 0x00000008 /*%< use virtual circuit */
#define RES_PRIMARY 0x00000010 /*%< query primary server only (!IMPL) */
#define RES_IGNTC 0x00000020 /*%< ignore trucation errors */
#define RES_RECURSE 0x00000040 /*%< recursion desired */
#define RES_DEFNAMES 0x00000080 /*%< use default domain name */
#define RES_STAYOPEN 0x00000100 /*%< Keep TCP socket open */
#define RES_DNSRCH 0x00000200 /*%< search up local domain tree */
#define RES_INSECURE1 0x00000400 /*%< type 1 security disabled */
#define RES_INSECURE2 0x00000800 /*%< type 2 security disabled */
#define RES_NOALIASES 0x00001000 /*%< shuts off HOSTALIASES feature */
#define RES_USE_INET6 0x00002000 /*%< use/map IPv6 in gethostbyname() */
#define RES_ROTATE 0x00004000 /*%< rotate ns list after each query */
#define RES_NOCHECKNAME 0x00008000 /*%< do not check names for sanity. */
#define RES_KEEPTSIG 0x00010000 /*%< do not strip TSIG records */
#define RES_BLAST 0x00020000 /*%< blast all recursive servers */
#define RES_NSID 0x00040000 /*%< request name server ID */
#define RES_NOTLDQUERY 0x00100000 /*%< don't unqualified name as a tld */
#define RES_USE_DNSSEC 0x00200000 /*%< use DNSSEC using OK bit in OPT */
/* #define RES_DEBUG2 0x00400000 */ /* nslookup internal */
/* KAME extensions: use higher bit to avoid conflict with ISC use */
#define RES_USE_DNAME 0x10000000 /*%< use DNAME */
#define RES_USE_EDNS0 0x40000000 /*%< use EDNS0 if configured */
#define RES_NO_NIBBLE2 0x80000000 /*%< disable alternate nibble lookup */
#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | \
RES_DNSRCH | RES_NO_NIBBLE2)
/*%
* Resolver "pfcode" values. Used by dig.
*/
#define RES_PRF_STATS 0x00000001
#define RES_PRF_UPDATE 0x00000002
#define RES_PRF_CLASS 0x00000004
#define RES_PRF_CMD 0x00000008
#define RES_PRF_QUES 0x00000010
#define RES_PRF_ANS 0x00000020
#define RES_PRF_AUTH 0x00000040
#define RES_PRF_ADD 0x00000080
#define RES_PRF_HEAD1 0x00000100
#define RES_PRF_HEAD2 0x00000200
#define RES_PRF_TTLID 0x00000400
#define RES_PRF_HEADX 0x00000800
#define RES_PRF_QUERY 0x00001000
#define RES_PRF_REPLY 0x00002000
#define RES_PRF_INIT 0x00004000
#define RES_PRF_TRUNC 0x00008000
/* 0x00010000 */
/* Things involving an internal (static) resolver context. */
#ifdef _REENTRANT
__BEGIN_DECLS
extern struct __res_state *__res_state(void);
__END_DECLS
#define _res (*__res_state())
#else
#ifdef __linux
__BEGIN_DECLS
extern struct __res_state * __res_state(void);
__END_DECLS
#endif
#ifndef __BIND_NOSTATIC
extern struct __res_state _res;
#endif
#endif
#ifndef __BIND_NOSTATIC
#define fp_nquery __fp_nquery
#define fp_query __fp_query
#define hostalias __hostalias
#define p_query __p_query
#define res_close __res_close
#define res_init __res_init
#define res_isourserver __res_isourserver
#define res_mkquery __res_mkquery
#define res_query __res_query
#define res_querydomain __res_querydomain
#define res_search __res_search
#define res_send __res_send
#define res_sendsigned __res_sendsigned
__BEGIN_DECLS
void fp_nquery __P((const u_char *, int, FILE *));
void fp_query __P((const u_char *, FILE *));
const char * hostalias __P((const char *));
void p_query __P((const u_char *));
void res_close __P((void));
int res_init __P((void));
int res_isourserver __P((const struct sockaddr_in *));
int res_mkquery __P((int, const char *, int, int, const u_char *,
int, const u_char *, u_char *, int));
int res_query __P((const char *, int, int, u_char *, int));
int res_querydomain __P((const char *, const char *, int, int,
u_char *, int));
int res_search __P((const char *, int, int, u_char *, int));
int res_send __P((const u_char *, int, u_char *, int));
int res_sendsigned __P((const u_char *, int, ns_tsig_key *,
u_char *, int));
__END_DECLS
#endif
#if !defined(SHARED_LIBBIND) || defined(LIB)
/*
* If libbind is a shared object (well, DLL anyway)
* 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
*
*/
extern const struct res_sym __p_key_syms[];
extern const struct res_sym __p_cert_syms[];
extern const struct res_sym __p_class_syms[];
extern const struct res_sym __p_type_syms[];
extern const struct res_sym __p_rcode_syms[];
#endif /* SHARED_LIBBIND */
#define b64_ntop __b64_ntop
#define b64_pton __b64_pton
#define dn_comp __dn_comp
#define dn_count_labels __dn_count_labels
#define dn_expand __dn_expand
#define dn_skipname __dn_skipname
#define fp_resstat __fp_resstat
#define loc_aton __loc_aton
#define loc_ntoa __loc_ntoa
#define p_cdname __p_cdname
#define p_cdnname __p_cdnname
#define p_class __p_class
#define p_fqname __p_fqname
#define p_fqnname __p_fqnname
#define p_option __p_option
#define p_secstodate __p_secstodate
#define p_section __p_section
#define p_time __p_time
#define p_type __p_type
#define p_rcode __p_rcode
#define p_sockun __p_sockun
#define putlong __putlong
#define putshort __putshort
#define res_dnok __res_dnok
#define res_findzonecut __res_findzonecut
#define res_findzonecut2 __res_findzonecut2
#define res_hnok __res_hnok
#define res_hostalias __res_hostalias
#define res_mailok __res_mailok
#define res_nameinquery __res_nameinquery
#define res_nclose __res_nclose
#define res_ninit __res_ninit
#define res_nmkquery __res_nmkquery
#define res_pquery __res_pquery
#define res_nquery __res_nquery
#define res_nquerydomain __res_nquerydomain
#define res_nsearch __res_nsearch
#define res_nsend __res_nsend
#define res_nsendsigned __res_nsendsigned
#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
#define res_nopt __res_nopt
#define res_nopt_rdata __res_nopt_rdata
#define res_ndestroy __res_ndestroy
#define res_nametoclass __res_nametoclass
#define res_nametotype __res_nametotype
#define res_setservers __res_setservers
#define res_getservers __res_getservers
#define res_buildprotolist __res_buildprotolist
#define res_destroyprotolist __res_destroyprotolist
#define res_destroyservicelist __res_destroyservicelist
#define res_get_nibblesuffix __res_get_nibblesuffix
#define res_get_nibblesuffix2 __res_get_nibblesuffix2
#define res_ourserver_p __res_ourserver_p
#define res_protocolname __res_protocolname
#define res_protocolnumber __res_protocolnumber
#define res_send_setqhook __res_send_setqhook
#define res_send_setrhook __res_send_setrhook
#define res_servicename __res_servicename
#define res_servicenumber __res_servicenumber
__BEGIN_DECLS
int res_hnok __P((const char *));
int res_ownok __P((const char *));
int res_mailok __P((const char *));
int res_dnok __P((const char *));
int sym_ston __P((const struct res_sym *, const char *, int *));
const char * sym_ntos __P((const struct res_sym *, int, int *));
const char * sym_ntop __P((const struct res_sym *, int, int *));
int b64_ntop __P((u_char const *, size_t, char *, size_t));
int b64_pton __P((char const *, u_char *, size_t));
int loc_aton __P((const char *, u_char *));
const char * loc_ntoa __P((const u_char *, char *));
int dn_skipname __P((const u_char *, const u_char *));
void putlong __P((u_int32_t, u_char *));
void putshort __P((u_int16_t, u_char *));
#ifndef __ultrix__
u_int16_t _getshort __P((const u_char *));
u_int32_t _getlong __P((const u_char *));
#endif
const char * p_class __P((int));
const char * p_time __P((u_int32_t));
const char * p_type __P((int));
const char * p_rcode __P((int));
const char * p_sockun __P((union res_sockaddr_union, char *, size_t));
const u_char * p_cdnname __P((const u_char *, const u_char *, int, FILE *));
const u_char * p_cdname __P((const u_char *, const u_char *, FILE *));
const u_char * p_fqnname __P((const u_char *, const u_char *,
int, char *, int));
const u_char * p_fqname __P((const u_char *, const u_char *, FILE *));
const char * p_option __P((u_long));
char * p_secstodate __P((u_long));
int dn_count_labels __P((const char *));
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 *,
const u_char *, const u_char *));
const char * p_section __P((int, int));
/* Things involving a resolver context. */
int res_ninit __P((res_state));
int res_nisourserver __P((const res_state,
const struct sockaddr_in *));
void fp_resstat __P((const res_state, FILE *));
void res_pquery __P((const res_state, const u_char *, int, FILE *));
const char * res_hostalias __P((const res_state, const char *,
char *, size_t));
int res_nquery __P((res_state, const char *, int, int,
u_char *, int));
int res_nsearch __P((res_state, const char *, int, int, u_char *,
int));
int res_nquerydomain __P((res_state, const char *, const char *,
int, int, u_char *, int));
int res_nmkquery __P((res_state, int, const char *, int, int,
const u_char *, int, const u_char *,
u_char *, int));
int res_nsend __P((res_state, const u_char *, int, u_char *, int));
int res_nsendsigned __P((res_state, const u_char *, int,
ns_tsig_key *, u_char *, int));
int res_findzonecut __P((res_state, const char *, ns_class, int,
char *, size_t, struct in_addr *, int));
int res_findzonecut2 __P((res_state, const char *, ns_class, int,
char *, size_t,
union res_sockaddr_union *, int));
void res_nclose __P((res_state));
int res_nopt __P((res_state, int, u_char *, int, int));
int res_nopt_rdata __P((res_state, int, u_char *, int, u_char *,
u_short, u_short, u_char *));
void res_send_setqhook __P((res_send_qhook));
void res_send_setrhook __P((res_send_rhook));
int __res_vinit __P((res_state, int));
void res_destroyservicelist __P((void));
const char * res_servicename __P((u_int16_t, const char *));
const char * res_protocolname __P((int));
void res_destroyprotolist __P((void));
void res_buildprotolist __P((void));
const char * res_get_nibblesuffix __P((res_state));
const char * res_get_nibblesuffix2 __P((res_state));
void res_ndestroy __P((res_state));
u_int16_t res_nametoclass __P((const char *, int *));
u_int16_t res_nametotype __P((const char *, int *));
void res_setservers __P((res_state,
const union res_sockaddr_union *, int));
int res_getservers __P((res_state,
union res_sockaddr_union *, int));
__END_DECLS
#endif /* !_RESOLV_H_ */
/*! \file */

View File

@ -1,9 +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

@ -15,12 +15,13 @@
* 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 17965 2006-06-29 17:45:22Z axeld $
* $Id: hesiod.h,v 1.4 2005/04/27 04:56:14 sra Exp $
*/
#ifndef _HESIOD_H_INCLUDED

View File

@ -16,16 +16,18 @@
*/
/*
* $Id: irp.h 15585 2005-12-19 13:26:54Z wkornew $
* $Id: irp.h,v 1.4 2005/04/27 04:56:15 sra Exp $
*/
#ifndef _IRP_H_INCLUDED
#define _IRP_H_INCLUDED
#define IRPD_TIMEOUT 30 /* seconds */
#define IRPD_MAXSESS 50 /* number of simultaneous sessions. */
#define IRPD_PORT 6660 /* 10 times the number of the beast. */
#define IRPD_PATH "/var/run/irpd" /* af_unix socket path */
/*! \file */
#define IRPD_TIMEOUT 30 /*%< seconds */
#define IRPD_MAXSESS 50 /*%< number of simultaneous sessions. */
#define IRPD_PORT 6660 /*%< 10 times the number of the beast. */
#define IRPD_PATH "/var/run/irpd" /*%< af_unix socket path */
/* If sets the environment variable IRPDSERVER to an IP address
(e.g. "192.5.5.1"), then that's the host the client expects irpd to be
@ -101,3 +103,5 @@ int irs_irp_get_full_response(struct irp_p *, int *, char *, size_t,
int irs_irp_read_line(struct irp_p *, char *, int);
#endif
/*! \file */

View File

@ -14,9 +14,16 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* $Id: irs.h,v 1.5 2005/04/27 04:56:15 sra Exp $
*/
#ifndef _IRS_H_INCLUDED
#define _IRS_H_INCLUDED
/*! \file */
#include <sys/types.h>
#include <arpa/nameser.h>
@ -26,12 +33,7 @@
#include <resolv.h>
#include <pwd.h>
#ifdef __cplusplus
extern "C" {
# define private private_data
#endif
/*
/*%
* This is the group map class.
*/
struct irs_gr {
@ -49,7 +51,7 @@ struct irs_gr {
void (*)(void *)));
};
/*
/*%
* This is the password map class.
*/
struct irs_pw {
@ -65,7 +67,7 @@ struct irs_pw {
void (*)(void *)));
};
/*
/*%
* This is the service map class.
*/
struct irs_sv {
@ -82,7 +84,7 @@ struct irs_sv {
void (*)(void *)));
};
/*
/*%
* This is the protocols map class.
*/
struct irs_pr {
@ -98,7 +100,7 @@ struct irs_pr {
void (*)(void *)));
};
/*
/*%
* This is the hosts map class.
*/
struct irs_ho {
@ -118,7 +120,7 @@ struct irs_ho {
const struct addrinfo *));
};
/*
/*%
* This is the networks map class.
*/
struct irs_nw {
@ -134,7 +136,7 @@ struct irs_nw {
void (*)(void *)));
};
/*
/*%
* This is the netgroups map class.
*/
struct irs_ng {
@ -149,7 +151,7 @@ struct irs_ng {
void (*minimize) __P((struct irs_ng *));
};
/*
/*%
* This is the generic map class, which copies the front of all others.
*/
struct irs_map {
@ -157,7 +159,7 @@ struct irs_map {
void (*close) __P((void *));
};
/*
/*%
* This is the accessor class. It contains pointers to all of the
* initializers for the map classes for a particular accessor.
*/
@ -176,21 +178,21 @@ struct irs_acc {
void (*)(void *)));
};
/*
/*%
* This is because the official definition of "struct netent" has no
* concept of CIDR even though it allows variant address families (on
* output but not input). The compatibility stubs convert the structs
* below into "struct netent"'s.
*/
struct nwent {
char *n_name; /* official name of net */
char **n_aliases; /* alias list */
int n_addrtype; /* net address type */
void *n_addr; /* network address */
int n_length; /* address length, in bits */
char *n_name; /*%< official name of net */
char **n_aliases; /*%< alias list */
int n_addrtype; /*%< net address type */
void *n_addr; /*%< network address */
int n_length; /*%< address length, in bits */
};
/*
/*%
* Hide external function names from POSIX.
*/
#define irs_gen_acc __irs_gen_acc
@ -240,7 +242,7 @@ struct nwent {
#define net_data_destroy __net_data_destroy
#define net_data_minimize __net_data_minimize
/*
/*%
* Externs.
*/
extern struct irs_acc * irs_gen_acc __P((const char *, const char *));
@ -251,7 +253,7 @@ extern struct irs_acc * irs_irp_acc __P((const char *));
extern void irs_destroy __P((void));
/*
/*%
* These forward declarations are for the semi-private functions in
* the get*.c files. Each of these funcs implements the real get*
* functionality and the standard versions are just wrappers that
@ -260,8 +262,7 @@ extern void irs_destroy __P((void));
* the /usr/include replacements.
*/
struct net_data; /* forward */
struct net_data; /*%< forward */
/*
* net_data_create gets a singleton net_data object. net_data_init
* creates as many net_data objects as times it is called. Clients using
@ -342,9 +343,6 @@ extern struct servent *getservbyport_p __P((int, const char *,
extern void setservent_p __P((int, struct net_data *));
extern void endservent_p __P((struct net_data *));
#ifdef __cplusplus
# undef private
}
#endif
#endif /*_IRS_H_INCLUDED*/
/*! \file */

View File

@ -1,22 +1,22 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1997-1999 by Internet Software Consortium.
* Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1997-2001 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.
*/
/*
* $Id: assertions.h 15585 2005-12-19 13:26:54Z wkornew $
* $Id: assertions.h,v 1.5 2008/11/14 02:36:51 marka Exp $
*/
#ifndef ASSERTIONS_H
@ -29,18 +29,19 @@ typedef enum {
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);
#ifdef CHECK_ALL
#if defined(CHECK_ALL) || defined(__COVERITY__)
#define CHECK_REQUIRE 1
#define CHECK_ENSURE 1
#define CHECK_INSIST 1
#define CHECK_INVARIANT 1
#endif
#ifdef CHECK_NONE
#if defined(CHECK_NONE) && !defined(__COVERITY__)
#define CHECK_REQUIRE 0
#define CHECK_ENSURE 0
#define CHECK_INSIST 0
@ -118,5 +119,5 @@ const char *assertion_type_to_text(assertion_type type);
#define INVARIANT(cond) ((void) (cond))
#define INVARIANT_ERR(cond) ((void) (cond))
#endif /* CHECK_INVARIANT */
#endif /* ASSERTIONS_H */
/*! \file */

View File

@ -19,9 +19,11 @@
*/
/*
* $Id: ctl.h 15585 2005-12-19 13:26:54Z wkornew $
* $Id: ctl.h,v 1.5 2005/04/27 04:56:17 sra Exp $
*/
/*! \file */
#include <sys/types.h>
#include <sys/socket.h>
@ -29,10 +31,9 @@
/* Macros. */
#define CTL_MORE 0x0001 /* More will be / should be sent. */
#define CTL_EXIT 0x0002 /* Close connection after this. */
#define CTL_DATA 0x0004 /* Go into / this is DATA mode. */
#define CTL_MORE 0x0001 /*%< More will be / should be sent. */
#define CTL_EXIT 0x0002 /*%< Close connection after this. */
#define CTL_DATA 0x0004 /*%< Go into / this is DATA mode. */
/* Types. */
struct ctl_cctx;
@ -107,3 +108,5 @@ void * ctl_getcsctx(struct ctl_sess *);
void * ctl_setcsctx(struct ctl_sess *, void *);
#endif /*ISC_CTL_H*/
/*! \file */

View File

@ -3,15 +3,14 @@
#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 */
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
*/
@ -59,58 +58,47 @@ typedef struct dst_key {
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_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_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 *);
@ -122,13 +110,12 @@ 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 */
#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_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() */
@ -178,3 +165,4 @@ u_int16_t dst_s_id_calc(const u_char *, const int);
#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 15585 2005-12-19 13:26:54Z wkornew $
* $Id: eventlib.h,v 1.7 2008/11/14 02:36:51 marka Exp $
*/
#ifndef _EVENTLIB_H
@ -29,6 +29,8 @@
#include <sys/time.h>
#include <stdio.h>
#include <isc/platform.h>
#ifndef __P
# define __EVENTLIB_P_DEFINED
# ifdef __STDC__
@ -76,6 +78,8 @@ typedef struct { unsigned char mask[256/8]; } evByteMask;
#define EV_WRITE 2
#define EV_EXCEPT 4
#define EV_WASNONBLOCKING 8 /* Internal library use. */
/* eventlib.c */
#define evCreate __evCreate
#define evSetDebug __evSetDebug
@ -198,3 +202,5 @@ int evDefer __P((evContext, evWaitFunc, void *));
#endif
#endif /*_EVENTLIB_H*/
/*! \file */

View File

@ -45,3 +45,5 @@ 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

@ -16,7 +16,7 @@
*/
/*
* $Id: irpmarshall.h 15585 2005-12-19 13:26:54Z wkornew $
* $Id: irpmarshall.h,v 1.4 2005/04/27 04:56:17 sra Exp $
*/
#ifndef _IRPMARSHALL_H_INCLUDED
@ -63,7 +63,8 @@ int irp_unmarshall_nw(struct nwent *, char *);
int irp_marshall_ne(struct netent *, char **, size_t *);
int irp_unmarshall_ne(struct netent *, char *);
/*
/*! \file
* \brief
* Functions to marshall and unmarshall various system data structures. We
* use a printable ascii format that is as close to various system config
* files as reasonable (e.g. /etc/passwd format).
@ -79,9 +80,7 @@ int irp_unmarshall_ne(struct netent *, char *);
*
* The following description is true for all the marshalling functions:
*
*/
/* int irp_marshall_XX(struct yyyy *XX, char **buffer, size_t *len);
* int irp_marshall_XX(struct yyyy *XX, char **buffer, size_t *len);
*
* The argument XX (of type struct passwd for example) is marshalled in the
* buffer pointed at by *BUFFER, which is of length *LEN. Returns 0
@ -101,9 +100,7 @@ int irp_unmarshall_ne(struct netent *, char *);
* to separate fields). Fields that have multiple subfields (like the
* gr_mem field in struct group) have their subparts separated by
* commas.
*/
/*
*
* int irp_unmarshall_XX(struct YYYYY *XX, char *buffer);
*
* The unmashalling functions break apart the buffer and store the

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)
@ -66,12 +67,16 @@
INSIST(LINKED(elt, link));\
if ((elt)->link.next != NULL) \
(elt)->link.next->link.prev = (elt)->link.prev; \
else \
else { \
INSIST((list).tail == (elt)); \
(list).tail = (elt)->link.prev; \
} \
if ((elt)->link.prev != NULL) \
(elt)->link.prev->link.next = (elt)->link.next; \
else \
else { \
INSIST((list).head == (elt)); \
(list).head = (elt)->link.next; \
} \
INIT_LINK_TYPE(elt, link, type); \
} while (0)
#define UNLINK(list, elt, link) \
@ -110,3 +115,4 @@
#define DEQUEUE(list, elt, link) UNLINK(list, elt, link)
#endif /* LIST_H */
/*! \file */

View File

@ -110,3 +110,4 @@ int log_free_channel(log_channel);
void log_close_debug_channels(log_context);
#endif /* !LOGGING_H */
/*! \file */

View File

@ -36,10 +36,6 @@
#define memstats __memstats
#define memactive __memactive
#ifdef __cplusplus
extern "C" {
#endif
int meminit(size_t, size_t);
void * __memget(size_t);
void __memput(void *, size_t);
@ -50,8 +46,5 @@ void __memput_record(void *, size_t, const char *, int);
void memstats(FILE *);
int memactive(void);
#ifdef __cplusplus
}
#endif
#endif /* MEMCLUSTER_H */
/*! \file */

View File

@ -0,0 +1,44 @@
/*
* Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1995-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.
*/
/*
* $Id: misc.h,v 1.7 2008/11/14 02:36:51 marka Exp $
*/
#ifndef _ISC_MISC_H
#define _ISC_MISC_H
/*! \file */
#include <stdio.h>
#include <sys/types.h>
#define bitncmp __bitncmp
/*#define isc_movefile __isc_movefile */
extern int bitncmp(const void *, const void *, int);
extern int isc_movefile(const char *, const char *);
extern int isc_gethexstring(unsigned char *, size_t, int, FILE *,
int *);
extern void isc_puthexstring(FILE *, const unsigned char *, size_t,
size_t, size_t, const char *);
extern void isc_tohex(const unsigned char *, size_t, char *);
#endif /*_ISC_MISC_H*/
/*! \file */

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2008 Internet Systems Consortium, Inc. ("ISC")
*
* 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: platform.h.in,v 1.3 2008/01/23 02:15:56 tbox Exp $ */
/*! \file */
#ifndef ISC_PLATFORM_H
#define ISC_PLATFORM_H
/*
* Define if the OS does not define struct timespec.
*/
#undef ISC_PLATFORM_NEEDTIMESPEC
#ifdef ISC_PLATFORM_NEEDTIMESPEC
#include <time.h> /* For time_t */
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
#endif
#endif

View File

@ -0,0 +1,36 @@
/*
* Copyright (C) 2008 Internet Systems Consortium, Inc. ("ISC")
*
* 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: platform.h.in,v 1.3 2008/01/23 02:15:56 tbox Exp $ */
/*! \file */
#ifndef ISC_PLATFORM_H
#define ISC_PLATFORM_H
/*
* Define if the OS does not define struct timespec.
*/
@ISC_PLATFORM_NEEDTIMESPEC@
#ifdef ISC_PLATFORM_NEEDTIMESPEC
#include <time.h> /* For time_t */
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
};
#endif
#endif

View File

@ -3,7 +3,7 @@
* vix 22jan93 [revisited; uses RCS, ANSI, POSIX; has bug fixes]
* vix 27jun86 [broken out of tree.c]
*
* $Id: tree.h 14574 2005-10-29 16:27:43Z bonefish $
* $Id: tree.h,v 1.3 2005/04/27 04:56:18 sra Exp $
*/
@ -19,7 +19,7 @@
# endif
#endif
/*
/*%
* tree_t is our package-specific anonymous pointer.
*/
#if defined(__STDC__) || defined(__GNUC__)
@ -28,7 +28,7 @@ typedef void *tree_t;
typedef char *tree_t;
#endif
/*
/*%
* Do not taint namespace
*/
#define tree_add __tree_add
@ -56,3 +56,4 @@ void tree_mung __P((tree **, void (*)()));
#endif /* _TREE_H_INCLUDED */
/*! \file */

View File

@ -0,0 +1,582 @@
/*
* ++Copyright++ 1980, 1983, 1988, 1993
* -
* Copyright (c) 1980, 1983, 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 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
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* -
* 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
* CORPORATION 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.
* -
* Portions Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by WIDE Project and
* its contributors.
* 4. Neither the name of the project 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 PROJECT 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
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* -
* --Copyright--
*/
/*
* @(#)netdb.h 8.1 (Berkeley) 6/2/93
* $Id: netdb.h,v 1.22 2008/02/28 05:34:17 marka Exp $
*/
#ifndef _NETDB_H_
#define _NETDB_H_
#include <sys/param.h>
#include <sys/types.h>
#if (!defined(BSD)) || (BSD < 199306)
# include <sys/bitypes.h>
#endif
#include <sys/cdefs.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#ifndef _PATH_HEQUIV
#define _PATH_HEQUIV "/etc/hosts.equiv"
#endif
#ifndef _PATH_HOSTS
#define _PATH_HOSTS "/etc/hosts"
#endif
#ifndef _PATH_NETWORKS
#define _PATH_NETWORKS "/etc/networks"
#endif
#ifndef _PATH_PROTOCOLS
#define _PATH_PROTOCOLS "/etc/protocols"
#endif
#ifndef _PATH_SERVICES
#define _PATH_SERVICES "/etc/services"
#endif
#if (__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)
#define __h_errno __h_errno_location
#endif
__BEGIN_DECLS
extern int * __h_errno __P((void));
__END_DECLS
#if defined(_REENTRANT) || \
(__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)
#define h_errno (*__h_errno())
#else
extern int h_errno;
#endif
/*%
* Structures returned by network data base library. All addresses are
* supplied in host order, and returned in network order (suitable for
* use in system calls).
*/
struct hostent {
char *h_name; /*%< official name of host */
char **h_aliases; /*%< alias list */
int h_addrtype; /*%< host address type */
int h_length; /*%< length of address */
char **h_addr_list; /*%< list of addresses from name server */
#define h_addr h_addr_list[0] /*%< address, for backward compatiblity */
};
/*%
* Assumption here is that a network number
* fits in an unsigned long -- probably a poor one.
*/
struct netent {
char *n_name; /*%< official name of net */
char **n_aliases; /*%< alias list */
int n_addrtype; /*%< net address type */
unsigned long n_net; /*%< network # */
};
struct servent {
char *s_name; /*%< official service name */
char **s_aliases; /*%< alias list */
int s_port; /*%< port # */
char *s_proto; /*%< protocol to use */
};
struct protoent {
char *p_name; /*%< official protocol name */
char **p_aliases; /*%< alias list */
int p_proto; /*%< protocol # */
};
struct addrinfo {
int ai_flags; /*%< AI_PASSIVE, AI_CANONNAME */
int ai_family; /*%< PF_xxx */
int ai_socktype; /*%< SOCK_xxx */
int ai_protocol; /*%< 0 or IPPROTO_xxx for IPv4 and IPv6 */
#if defined(sun) && defined(_SOCKLEN_T)
#ifdef __sparcv9
int _ai_pad;
#endif
socklen_t ai_addrlen;
#else
size_t ai_addrlen; /*%< length of ai_addr */
#endif
#ifdef __linux
struct sockaddr *ai_addr; /*%< binary address */
char *ai_canonname; /*%< canonical name for hostname */
#else
char *ai_canonname; /*%< canonical name for hostname */
struct sockaddr *ai_addr; /*%< binary address */
#endif
struct addrinfo *ai_next; /*%< next structure in linked list */
};
/*%
* Error return codes from gethostbyname() and gethostbyaddr()
* (left in extern int h_errno).
*/
#define NETDB_INTERNAL -1 /*%< see errno */
#define NETDB_SUCCESS 0 /*%< no problem */
#define HOST_NOT_FOUND 1 /*%< Authoritative Answer Host not found */
#define TRY_AGAIN 2 /*%< Non-Authoritive Host not found, or SERVERFAIL */
#define NO_RECOVERY 3 /*%< Non recoverable errors, FORMERR, REFUSED, NOTIMP */
#define NO_DATA 4 /*%< Valid name, no data record of requested type */
#define NO_ADDRESS NO_DATA /*%< no address, look for MX record */
/*
* Error return codes from getaddrinfo()
*/
#define EAI_ADDRFAMILY 1 /*%< address family for hostname not supported */
#define EAI_AGAIN 2 /*%< temporary failure in name resolution */
#define EAI_BADFLAGS 3 /*%< invalid value for ai_flags */
#define EAI_FAIL 4 /*%< non-recoverable failure in name resolution */
#define EAI_FAMILY 5 /*%< ai_family not supported */
#define EAI_MEMORY 6 /*%< memory allocation failure */
#define EAI_NODATA 7 /*%< no address associated with hostname */
#define EAI_NONAME 8 /*%< hostname nor servname provided, or not known */
#define EAI_SERVICE 9 /*%< servname not supported for ai_socktype */
#define EAI_SOCKTYPE 10 /*%< ai_socktype not supported */
#define EAI_SYSTEM 11 /*%< system error returned in errno */
#define EAI_BADHINTS 12
#define EAI_PROTOCOL 13
#define EAI_MAX 14
/*%
* Flag values for getaddrinfo()
*/
#define AI_PASSIVE 0x00000001
#define AI_CANONNAME 0x00000002
#define AI_NUMERICHOST 0x00000004
#define AI_MASK 0x00000007
/*%
* Flag values for getipnodebyname()
*/
#define AI_V4MAPPED 0x00000008
#define AI_ALL 0x00000010
#define AI_ADDRCONFIG 0x00000020
#define AI_DEFAULT (AI_V4MAPPED|AI_ADDRCONFIG)
/*%
* Constants for getnameinfo()
*/
#define NI_MAXHOST 1025
#define NI_MAXSERV 32
/*%
* Flag values for getnameinfo()
*/
#define NI_NOFQDN 0x00000001
#define NI_NUMERICHOST 0x00000002
#define NI_NAMEREQD 0x00000004
#define NI_NUMERICSERV 0x00000008
#define NI_DGRAM 0x00000010
#define NI_WITHSCOPEID 0x00000020
#define NI_NUMERICSCOPE 0x00000040
/*%
* Scope delimit character
*/
#define SCOPE_DELIMITER '%'
#ifdef _REENTRANT
#if defined (__hpux) || defined(__osf__) || defined(_AIX)
#define _MAXALIASES 35
#define _MAXLINELEN 1024
#define _MAXADDRS 35
#define _HOSTBUFSIZE (BUFSIZ + 1)
struct hostent_data {
struct in_addr host_addr;
char *h_addr_ptrs[_MAXADDRS + 1];
char hostaddr[_MAXADDRS];
char hostbuf[_HOSTBUFSIZE];
char *host_aliases[_MAXALIASES];
char *host_addrs[2];
FILE *hostf;
#ifdef __osf__
int svc_gethostflag;
int svc_gethostbind;
#endif
#ifdef __hpux
short _nsw_src;
short _flags;
char *current;
int currentlen;
#endif
};
struct netent_data {
FILE *net_fp;
#if defined(__osf__) || defined(_AIX)
char line[_MAXLINELEN];
#endif
#ifdef __hpux
char line[_MAXLINELEN+1];
#endif
char *net_aliases[_MAXALIASES];
#ifdef __osf__
int _net_stayopen;
int svc_getnetflag;
#endif
#ifdef __hpux
short _nsw_src;
short _flags;
char *current;
int currentlen;
#endif
#ifdef _AIX
int _net_stayopen;
char *current;
int currentlen;
void *_net_reserv1; /* reserved for future use */
void *_net_reserv2; /* reserved for future use */
#endif
};
struct protoent_data {
FILE *proto_fp;
#ifdef _AIX
int _proto_stayopen;
char line[_MAXLINELEN];
#endif
#ifdef __osf__
char line[1024];
#endif
#ifdef __hpux
char line[_MAXLINELEN+1];
#endif
char *proto_aliases[_MAXALIASES];
#ifdef __osf__
int _proto_stayopen;
int svc_getprotoflag;
#endif
#ifdef __hpux
short _nsw_src;
short _flags;
char *current;
int currentlen;
#endif
#ifdef _AIX
int currentlen;
char *current;
void *_proto_reserv1; /* reserved for future use */
void *_proto_reserv2; /* reserved for future use */
#endif
};
struct servent_data {
FILE *serv_fp;
#if defined(__osf__) || defined(_AIX)
char line[_MAXLINELEN];
#endif
#ifdef __hpux
char line[_MAXLINELEN+1];
#endif
char *serv_aliases[_MAXALIASES];
#ifdef __osf__
int _serv_stayopen;
int svc_getservflag;
#endif
#ifdef __hpux
short _nsw_src;
short _flags;
char *current;
int currentlen;
#endif
#ifdef _AIX
int _serv_stayopen;
char *current;
int currentlen;
void *_serv_reserv1; /* reserved for future use */
void *_serv_reserv2; /* reserved for future use */
#endif
};
#endif
#endif
__BEGIN_DECLS
void endhostent __P((void));
void endnetent __P((void));
void endprotoent __P((void));
void endservent __P((void));
void freehostent __P((struct hostent *));
struct hostent *gethostbyaddr __P((const char *, int, int));
struct hostent *gethostbyname __P((const char *));
struct hostent *gethostbyname2 __P((const char *, int));
struct hostent *gethostent __P((void));
struct hostent *getipnodebyaddr __P((const void *, size_t, int, int *));
struct hostent *getipnodebyname __P((const char *, int, int, int *));
struct netent *getnetbyaddr __P((unsigned long, int));
struct netent *getnetbyname __P((const char *));
struct netent *getnetent __P((void));
struct protoent *getprotobyname __P((const char *));
struct protoent *getprotobynumber __P((int));
struct protoent *getprotoent __P((void));
struct servent *getservbyname __P((const char *, const char *));
struct servent *getservbyport __P((int, const char *));
struct servent *getservent __P((void));
void herror __P((const char *));
const char *hstrerror __P((int));
void sethostent __P((int));
/* void sethostfile __P((const char *)); */
void setnetent __P((int));
void setprotoent __P((int));
void setservent __P((int));
int getaddrinfo __P((const char *, const char *,
const struct addrinfo *, struct addrinfo **));
int getnameinfo __P((const struct sockaddr *, size_t, char *,
size_t, char *, size_t, int));
void freeaddrinfo __P((struct addrinfo *));
const char *gai_strerror __P((int));
struct hostent *getipnodebyname __P((const char *, int, int, int *));
struct hostent *getipnodebyaddr __P((const void *, size_t, int, int *));
void freehostent __P((struct hostent *));
#ifdef __GLIBC__
int getnetgrent __P((/* const */ char **, /* const */ char **,
/* const */ char **));
void setnetgrent __P((const char *));
void endnetgrent __P((void));
int innetgr __P((const char *, const char *, const char *,
const char *));
#endif
#ifdef _REENTRANT
#if defined(__hpux) || defined(__osf__) || defined(_AIX)
int gethostbyaddr_r __P((const char *, int, int, struct hostent *,
struct hostent_data *));
int gethostbyname_r __P((const char *, struct hostent *,
struct hostent_data *));
int gethostent_r __P((struct hostent *, struct hostent_data *));
#if defined(_AIX)
void sethostent_r __P((int, struct hostent_data *));
#else
int sethostent_r __P((int, struct hostent_data *));
#endif
#if defined(__hpux)
int endhostent_r __P((struct hostent_data *));
#else
void endhostent_r __P((struct hostent_data *));
#endif
#if defined(__hpux) || defined(__osf__)
int getnetbyaddr_r __P((int, int,
struct netent *, struct netent_data *));
#else
int getnetbyaddr_r __P((long, int,
struct netent *, struct netent_data *));
#endif
int getnetbyname_r __P((const char *,
struct netent *, struct netent_data *));
int getnetent_r __P((struct netent *, struct netent_data *));
int setnetent_r __P((int, struct netent_data *));
#ifdef __hpux
int endnetent_r __P((struct netent_data *buffer));
#else
void endnetent_r __P((struct netent_data *buffer));
#endif
int getprotobyname_r __P((const char *,
struct protoent *, struct protoent_data *));
int getprotobynumber_r __P((int,
struct protoent *, struct protoent_data *));
int getprotoent_r __P((struct protoent *, struct protoent_data *));
int setprotoent_r __P((int, struct protoent_data *));
#ifdef __hpux
int endprotoent_r __P((struct protoent_data *));
#else
void endprotoent_r __P((struct protoent_data *));
#endif
int getservbyname_r __P((const char *, const char *,
struct servent *, struct servent_data *));
int getservbyport_r __P((int, const char *,
struct servent *, struct servent_data *));
int getservent_r __P((struct servent *, struct servent_data *));
int setservent_r __P((int, struct servent_data *));
#ifdef __hpux
int endservent_r __P((struct servent_data *));
#else
void endservent_r __P((struct servent_data *));
#endif
#ifdef _AIX
int setnetgrent_r __P((char *, void **));
void endnetgrent_r __P((void **));
/*
* Note: AIX's netdb.h declares innetgr_r() as:
* int innetgr_r(char *, char *, char *, char *, struct innetgr_data *);
*/
int innetgr_r __P((const char *, const char *, const char *,
const char *));
#endif
#else
/* defined(sun) || defined(bsdi) */
#if defined(__GLIBC__) || defined(__FreeBSD__) && (__FreeBSD_version + 0 >= 601103)
int gethostbyaddr_r __P((const char *, int, int, struct hostent *,
char *, size_t, struct hostent **, int *));
int gethostbyname_r __P((const char *, struct hostent *,
char *, size_t, struct hostent **, int *));
int gethostent_r __P((struct hostent *, char *, size_t,
struct hostent **, int *));
#else
struct hostent *gethostbyaddr_r __P((const char *, int, int, struct hostent *,
char *, int, int *));
struct hostent *gethostbyname_r __P((const char *, struct hostent *,
char *, int, int *));
struct hostent *gethostent_r __P((struct hostent *, char *, int, int *));
#endif
void sethostent_r __P((int));
void endhostent_r __P((void));
#if defined(__GLIBC__) || defined(__FreeBSD__) && (__FreeBSD_version + 0 >= 601103)
int getnetbyname_r __P((const char *, struct netent *,
char *, size_t, struct netent **, int*));
int getnetbyaddr_r __P((unsigned long int, int, struct netent *,
char *, size_t, struct netent **, int*));
int getnetent_r __P((struct netent *, char *, size_t, struct netent **, int*));
#else
struct netent *getnetbyname_r __P((const char *, struct netent *,
char *, int));
struct netent *getnetbyaddr_r __P((long, int, struct netent *,
char *, int));
struct netent *getnetent_r __P((struct netent *, char *, int));
#endif
void setnetent_r __P((int));
void endnetent_r __P((void));
#if defined(__GLIBC__) || defined(__FreeBSD__) && (__FreeBSD_version + 0 >= 601103)
int getprotobyname_r __P((const char *, struct protoent *, char *,
size_t, struct protoent **));
int getprotobynumber_r __P((int, struct protoent *, char *, size_t,
struct protoent **));
int getprotoent_r __P((struct protoent *, char *, size_t, struct protoent **));
#else
struct protoent *getprotobyname_r __P((const char *,
struct protoent *, char *, int));
struct protoent *getprotobynumber_r __P((int,
struct protoent *, char *, int));
struct protoent *getprotoent_r __P((struct protoent *, char *, int));
#endif
void setprotoent_r __P((int));
void endprotoent_r __P((void));
#if defined(__GLIBC__) || defined(__FreeBSD__) && (__FreeBSD_version + 0 >= 601103)
int getservbyname_r __P((const char *name, const char *,
struct servent *, char *, size_t, struct servent **));
int getservbyport_r __P((int port, const char *,
struct servent *, char *, size_t, struct servent **));
int getservent_r __P((struct servent *, char *, size_t, struct servent **));
#else
struct servent *getservbyname_r __P((const char *name, const char *,
struct servent *, char *, int));
struct servent *getservbyport_r __P((int port, const char *,
struct servent *, char *, int));
struct servent *getservent_r __P((struct servent *, char *, int));
#endif
void setservent_r __P((int));
void endservent_r __P((void));
#ifdef __GLIBC__
int getnetgrent_r __P((char **, char **, char **, char *, size_t));
#endif
#endif
#endif
__END_DECLS
/* This is nec'y to make this include file properly replace the sun version. */
#ifdef sun
#ifdef __GNU_LIBRARY__
#include <rpc/netdb.h>
#else
struct rpcent {
char *r_name; /*%< name of server for this rpc program */
char **r_aliases; /*%< alias list */
int r_number; /*%< rpc program number */
};
struct rpcent *getrpcbyname(), *getrpcbynumber(), *getrpcent();
#endif /* __GNU_LIBRARY__ */
#endif /* sun */
#endif /* !_NETDB_H_ */
/*! \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,34 +16,36 @@
*/
/*
* $Id: res_update.h 15585 2005-12-19 13:26:54Z wkornew $
* $Id: res_update.h,v 1.3 2005/04/27 04:56:15 sra Exp $
*/
#ifndef __RES_UPDATE_H
#define __RES_UPDATE_H
/*! \file */
#include <sys/types.h>
#include <arpa/nameser.h>
#include <isc/list.h>
#include <resolv.h>
/*
/*%
* This RR-like structure is particular to UPDATE.
*/
struct ns_updrec {
LINK(struct ns_updrec) r_link, r_glink;
ns_sect r_section; /* ZONE/PREREQUISITE/UPDATE */
char * r_dname; /* owner of the RR */
ns_class r_class; /* class number */
ns_type r_type; /* type number */
u_int32_t r_ttl; /* time to live */
u_char * r_data; /* rdata fields as text string */
u_int r_size; /* size of r_data field */
int r_opcode; /* type of operation */
ns_sect r_section; /*%< ZONE/PREREQUISITE/UPDATE */
char * r_dname; /*%< owner of the RR */
ns_class r_class; /*%< class number */
ns_type r_type; /*%< type number */
u_int32_t r_ttl; /*%< time to live */
u_char * r_data; /*%< rdata fields as text string */
u_int r_size; /*%< size of r_data field */
int r_opcode; /*%< type of operation */
/* following fields for private use by the resolver/server routines */
struct databuf *r_dp; /* databuf to process */
struct databuf *r_deldp; /* databuf's deleted/overwritten */
u_int r_zone; /* zone number on server */
struct databuf *r_dp; /*%< databuf to process */
struct databuf *r_deldp; /*%< databuf's deleted/overwritten */
u_int r_zone; /*%< zone number on server */
};
typedef struct ns_updrec ns_updrec;
typedef LIST(ns_updrec) ns_updque;
@ -63,3 +65,5 @@ int res_nmkupdate __P((res_state, ns_updrec *, u_char *, int));
int res_nupdate __P((res_state, ns_updrec *, ns_tsig_key *));
#endif /*__RES_UPDATE_H*/
/*! \file */

View File

@ -0,0 +1,47 @@
#ifndef _RESOLV_MT_H
#define _RESOLV_MT_H
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
/* Access functions for the libresolv private interface */
int __res_enable_mt(void);
int __res_disable_mt(void);
/* Per-thread context */
typedef struct {
int no_hosts_fallback_private;
int retry_save;
int retry_private;
char inet_nsap_ntoa_tmpbuf[255*3];
char sym_ntos_unname[20];
char sym_ntop_unname[20];
char p_option_nbuf[40];
char p_time_nbuf[40];
char precsize_ntoa_retbuf[sizeof "90000000.00"];
char loc_ntoa_tmpbuf[sizeof
"1000 60 60.000 N 1000 60 60.000 W -12345678.00m 90000000.00m 90000000.00m 90000000.00m"];
char p_secstodate_output[15];
} mtctxres_t;
/* Thread-specific data (TSD) */
mtctxres_t *___mtctxres(void);
#define mtctxres (___mtctxres())
/* Various static data that should be TSD */
#define sym_ntos_unname (mtctxres->sym_ntos_unname)
#define sym_ntop_unname (mtctxres->sym_ntop_unname)
#define inet_nsap_ntoa_tmpbuf (mtctxres->inet_nsap_ntoa_tmpbuf)
#define p_option_nbuf (mtctxres->p_option_nbuf)
#define p_time_nbuf (mtctxres->p_time_nbuf)
#define precsize_ntoa_retbuf (mtctxres->precsize_ntoa_retbuf)
#define loc_ntoa_tmpbuf (mtctxres->loc_ntoa_tmpbuf)
#define p_secstodate_output (mtctxres->p_secstodate_output)
#endif /* _RESOLV_MT_H */

View File

@ -0,0 +1 @@
#include <stdint.h>

View File

View File

@ -1,7 +1,7 @@
/*
* Copyright (c) 1983, 1990, 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 +17,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 +33,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
@ -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 24646 2008-03-29 12:41:04Z bonefish $";
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"
@ -85,7 +85,7 @@ static const char rcsid[] = "$Id: inet_addr.c 24646 2008-03-29 12:41:04Z bonefis
#include "port_after.h"
/*
/*%
* Ascii internet address interpretation routine.
* The value returned is in network order.
*/
@ -98,7 +98,7 @@ inet_addr(const char *cp) {
return (INADDR_NONE);
}
/*
/*%
* Check whether "cp" is a valid ascii representation
* of an Internet address and convert to a binary address.
* Returns 1 if the address is valid, 0 if not.
@ -140,7 +140,7 @@ inet_aton(const char *cp, struct in_addr *addr) {
val = (val * base) + (c - '0');
c = *++cp;
digit = 1;
} else if (base == 16 && isascii(c) &&
} else if (base == 16 && isascii(c) &&
isxdigit((unsigned char)c)) {
val = (val << 4) |
(c + 10 - (islower((unsigned char)c) ? 'a' : 'A'));
@ -179,22 +179,22 @@ inet_aton(const char *cp, struct in_addr *addr) {
*/
n = pp - parts + 1;
switch (n) {
case 1: /* a -- 32 bits */
case 1: /*%< a -- 32 bits */
break;
case 2: /* a.b -- 8.24 bits */
case 2: /*%< a.b -- 8.24 bits */
if (val > 0xffffffU)
return (0);
val |= parts[0] << 24;
break;
case 3: /* a.b.c -- 8.8.16 bits */
case 3: /*%< a.b.c -- 8.8.16 bits */
if (val > 0xffffU)
return (0);
val |= (parts[0] << 24) | (parts[1] << 16);
break;
case 4: /* a.b.c.d -- 8.8.8.8 bits */
case 4: /*%< a.b.c.d -- 8.8.8.8 bits */
if (val > 0xffU)
return (0);
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
@ -205,7 +205,4 @@ inet_aton(const char *cp, struct in_addr *addr) {
return (1);
}
#undef inet_addr
#undef inet_aton
#pragma weak inet_addr=__inet_addr
#pragma weak inet_aton=__inet_aton
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_cidr_ntop.c 24646 2008-03-29 12:41:04Z bonefish $";
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"
@ -40,12 +40,12 @@ static const char rcsid[] = "$Id: inet_cidr_ntop.c 24646 2008-03-29 12:41:04Z bo
# define SPRINTF(x) ((size_t)sprintf x)
#endif
static char * inet_cidr_ntop_ipv4 __P((const u_char *src, int bits,
char *dst, size_t size));
static char * inet_cidr_ntop_ipv6 __P((const u_char *src, int bits,
char *dst, size_t size));
static char *
inet_cidr_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size);
static char *
inet_cidr_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size);
/*
/*%
* char *
* inet_cidr_ntop(af, src, bits, dst, size)
* convert network address from network to presentation format.
@ -92,7 +92,7 @@ decoct(const u_char *src, int bytes, char *dst, size_t size) {
return (dst - odst);
}
/*
/*%
* static char *
* inet_cidr_ntop_ipv4(src, bits, dst, size)
* convert IPv4 network address from network to presentation format.
@ -178,7 +178,9 @@ inet_cidr_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) {
for (i = 0; i < NS_IN6ADDRSZ; i++)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1;
best.len = 0;
cur.base = -1;
cur.len = 0;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
if (words[i] == 0) {
if (cur.base == -1)
@ -258,5 +260,4 @@ inet_cidr_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) {
return (dst);
}
#undef inet_cidr_ntop
#pragma weak inet_cidr_ntop=__inet_cidr_ntop
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_cidr_pton.c 24646 2008-03-29 12:41:04Z bonefish $";
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"
@ -49,7 +49,7 @@ static int inet_cidr_pton_ipv6 __P((const char *src, u_char *dst,
static int getbits(const char *, int ipv6);
/*
/*%
* int
* inet_cidr_pton(af, src, dst, *bits)
* convert network address from presentation to network format.
@ -204,7 +204,7 @@ inet_cidr_pton_ipv6(const char *src, u_char *dst, int *pbits) {
inet_cidr_pton_ipv4(curtok, tp, &bits, 1) == 0) {
tp += NS_INADDRSZ;
saw_xdigit = 0;
break; /* '\0' was seen by inet_pton4(). */
break; /*%< '\\0' was seen by inet_pton4(). */
}
if (ch == '/') {
bits = getbits(src, 1);
@ -256,23 +256,22 @@ getbits(const char *src, int ipv6) {
int bits = 0;
char *cp, ch;
if (*src == '\0') /* syntax */
if (*src == '\0') /*%< syntax */
return (-2);
do {
ch = *src++;
cp = strchr(digits, ch);
if (cp == NULL) /* syntax */
if (cp == NULL) /*%< syntax */
return (-2);
bits *= 10;
bits += cp - digits;
if (bits == 0 && *src != '\0') /* no leading zeros */
if (bits == 0 && *src != '\0') /*%< no leading zeros */
return (-2);
if (bits > (ipv6 ? 128 : 32)) /* range error */
if (bits > (ipv6 ? 128 : 32)) /*%< range error */
return (-2);
} while (*src != '\0');
return (bits);
}
#undef inet_cidr_pton
#pragma weak inet_cidr_pton=__inet_cidr_pton
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char rcsid[] = "$Id: inet_data.c 15570 2005-12-16 22:38:13Z wkornew $";
static char rcsid[] = "$Id: inet_data.c,v 1.4 2005/04/27 04:56:19 sra Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@ -42,3 +42,5 @@ static char rcsid[] = "$Id: inet_data.c 15570 2005-12-16 22:38:13Z wkornew $";
const struct in6_addr isc_in6addr_any = IN6ADDR_ANY_INIT;
const struct in6_addr isc_in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
/*! \file */

View File

@ -43,7 +43,7 @@ static const char sccsid[] = "@(#)inet_lnaof.c 8.1 (Berkeley) 6/4/93";
#include "port_after.h"
/*
/*%
* Return the local network address portion of an
* internet address; handles class a/b/c network
* number formats.
@ -62,5 +62,4 @@ inet_lnaof(in)
return ((i)&IN_CLASSC_HOST);
}
#undef inet_lnaof
#pragma weak inet_lnaof=__inet_lnaof
/*! \file */

View File

@ -43,7 +43,7 @@ static const char sccsid[] = "@(#)inet_makeaddr.c 8.1 (Berkeley) 6/4/93";
#include "port_after.h"
/*
/*%
* Formulate an Internet address from network + host. Used in
* building addresses stored in the ifnet structure.
*/
@ -65,5 +65,4 @@ inet_makeaddr(net, host)
return (a);
}
#undef inet_makeaddr
#pragma weak inet_makeaddr=__inet_makeaddr
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_net_ntop.c 24646 2008-03-29 12:41:04Z bonefish $";
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"
@ -44,7 +44,7 @@ static char * inet_net_ntop_ipv4 __P((const u_char *src, int bits,
static char * inet_net_ntop_ipv6 __P((const u_char *src, int bits,
char *dst, size_t size));
/*
/*%
* char *
* inet_net_ntop(af, src, bits, dst, size)
* convert network number from network to presentation format.
@ -73,7 +73,7 @@ inet_net_ntop(af, src, bits, dst, size)
}
}
/*
/*%
* static char *
* inet_net_ntop_ipv4(src, bits, dst, size)
* convert IPv4 network number from network to presentation format.
@ -148,7 +148,7 @@ inet_net_ntop_ipv4(src, bits, dst, size)
return (NULL);
}
/*
/*%
* static char *
* inet_net_ntop_ipv6(src, bits, fakebits, dst, size)
* convert IPv6 network number from network to presentation format.
@ -264,7 +264,7 @@ inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) {
}
}
/* Format CIDR /width. */
SPRINTF((cp, "/%u", bits));
sprintf(cp, "/%u", bits);
if (strlen(outbuf) + 1 > size)
goto emsgsize;
strcpy(dst, outbuf);
@ -276,5 +276,4 @@ emsgsize:
return (NULL);
}
#undef inet_net_ntop
#pragma weak inet_net_ntop=__inet_net_ntop
/*! \file */

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 24646 2008-03-29 12:41:04Z bonefish $";
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"
@ -42,7 +42,7 @@ static const char rcsid[] = "$Id: inet_net_pton.c 24646 2008-03-29 12:41:04Z bon
# define SPRINTF(x) ((size_t)sprintf x)
#endif
/*
/*%
* static int
* inet_net_pton_ipv4(src, dst, size)
* convert IPv4 network number from presentation to network format.
@ -73,7 +73,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) {
if (size <= 0U)
goto emsgsize;
dirty = 0;
src++; /* skip x or X. */
src++; /*%< skip x or X. */
while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) {
if (isupper(ch))
ch = tolower(ch);
@ -90,7 +90,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) {
dirty = 0;
}
}
if (dirty) { /* Odd trailing nybble? */
if (dirty) { /*%< Odd trailing nybble? */
if (size-- <= 0U)
goto emsgsize;
*dst++ = (u_char) (tmp << 4);
@ -126,18 +126,18 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) {
if (ch == '/' && isascii((unsigned char)(src[0])) &&
isdigit((unsigned char)(src[0])) && dst > odst) {
/* CIDR width specifier. Nothing can follow it. */
ch = *src++; /* Skip over the /. */
ch = *src++; /*%< Skip over the /. */
bits = 0;
do {
n = strchr(digits, ch) - digits;
INSIST(n >= 0 && n <= 9);
bits *= 10;
bits += n;
if (bits > 32)
goto enoent;
} while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch));
if (ch != '\0')
goto enoent;
if (bits > 32)
goto emsgsize;
}
/* Firey death and destruction unless we prefetched EOS. */
@ -149,15 +149,15 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) {
goto enoent;
/* If no CIDR spec was given, infer width from net class. */
if (bits == -1) {
if (*odst >= 240) /* Class E */
if (*odst >= 240) /*%< Class E */
bits = 32;
else if (*odst >= 224) /* Class D */
else if (*odst >= 224) /*%< Class D */
bits = 8;
else if (*odst >= 192) /* Class C */
else if (*odst >= 192) /*%< Class C */
bits = 24;
else if (*odst >= 128) /* Class B */
else if (*odst >= 128) /*%< Class B */
bits = 16;
else /* Class A */
else /*%< Class A */
bits = 8;
/* If imputed mask is narrower than specified octets, widen. */
if (bits < ((dst - odst) * 8))
@ -200,11 +200,11 @@ getbits(const char *src, int *bitsp) {
pch = strchr(digits, ch);
if (pch != NULL) {
if (n++ != 0 && val == 0) /* no leading zeros */
if (n++ != 0 && val == 0) /*%< no leading zeros */
return (0);
val *= 10;
val += (pch - digits);
if (val > 128) /* range */
if (val > 128) /*%< range */
return (0);
continue;
}
@ -231,16 +231,16 @@ getv4(const char *src, u_char *dst, int *bitsp) {
pch = strchr(digits, ch);
if (pch != NULL) {
if (n++ != 0 && val == 0) /* no leading zeros */
if (n++ != 0 && val == 0) /*%< no leading zeros */
return (0);
val *= 10;
val += (pch - digits);
if (val > 255) /* range */
if (val > 255) /*%< range */
return (0);
continue;
}
if (ch == '.' || ch == '/') {
if (dst - odst > 3) /* too many octets? */
if (dst - odst > 3) /*%< too many octets? */
return (0);
*dst++ = val;
if (ch == '/')
@ -253,7 +253,7 @@ getv4(const char *src, u_char *dst, int *bitsp) {
}
if (n == 0)
return (0);
if (dst - odst > 3) /* too many octets? */
if (dst - odst > 3) /*%< too many octets? */
return (0);
*dst++ = val;
return (1);
@ -322,7 +322,7 @@ inet_net_pton_ipv6(const char *src, u_char *dst, size_t size) {
tp += NS_INADDRSZ;
saw_xdigit = 0;
ipv4 = 1;
break; /* '\0' was seen by inet_pton4(). */
break; /*%< '\\0' was seen by inet_pton4(). */
}
if (ch == '/' && getbits(src, &bits) > 0)
break;
@ -378,7 +378,7 @@ inet_net_pton_ipv6(const char *src, u_char *dst, size_t size) {
return (-1);
}
/*
/*%
* int
* inet_net_pton(af, src, dst, size)
* convert network number from presentation to network format.
@ -404,5 +404,4 @@ inet_net_pton(int af, const char *src, void *dst, size_t size) {
}
}
#undef inet_net_pton
#pragma weak inet_net_pton=__inet_net_pton
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_neta.c 24646 2008-03-29 12:41:04Z bonefish $";
static const char rcsid[] = "$Id: inet_neta.c,v 1.3 2005/04/27 04:56:20 sra Exp $";
#endif
#include "port_before.h"
@ -38,7 +38,7 @@ static const char rcsid[] = "$Id: inet_neta.c 24646 2008-03-29 12:41:04Z bonefis
# define SPRINTF(x) ((size_t)sprintf x)
#endif
/*
/*%
* char *
* inet_neta(src, dst, size)
* format a u_long network number into presentation format.
@ -86,5 +86,4 @@ inet_neta(src, dst, size)
return (NULL);
}
#undef inet_neta
#pragma weak inet_neta=__inet_neta
/*! \file */

View File

@ -43,7 +43,7 @@ static const char sccsid[] = "@(#)inet_netof.c 8.1 (Berkeley) 6/4/93";
#include "port_after.h"
/*
/*%
* Return the network number from an internet
* address; handles class a/b/c network #'s.
*/
@ -61,5 +61,4 @@ inet_netof(in)
return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT);
}
#undef inet_netof
#pragma weak inet_netof=__inet_netof
/*! \file */

View File

@ -44,7 +44,7 @@ static const char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93";
#include "port_after.h"
/*
/*%
* Internet network address interpretation routine.
* The library routines call this routine to interpret
* network numbers.
@ -84,9 +84,9 @@ again:
}
if (!digit)
return (INADDR_NONE);
if (pp >= parts + 4 || val > 0xffU)
return (INADDR_NONE);
if (*cp == '.') {
if (pp >= parts + 4 || val > 0xffU)
return (INADDR_NONE);
*pp++ = val, cp++;
goto again;
}
@ -103,5 +103,4 @@ again:
return (val);
}
#undef inet_network
#pragma weak inet_network=__inet_network
/*! \file */

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 18891 2006-09-19 16:17:02Z korli $";
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"
@ -48,7 +48,7 @@ static const char rcsid[] = "$Id: inet_ntoa.c 18891 2006-09-19 16:17:02Z korli $
#include "port_after.h"
/*
/*%
* Convert network-format internet address
* to base 256 d.d.d.d representation.
*/
@ -61,6 +61,4 @@ inet_ntoa(struct in_addr in) {
return (ret);
}
#undef inet_ntoa
#pragma weak inet_ntoa=__inet_ntoa
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_ntop.c 24646 2008-03-29 12:41:04Z bonefish $";
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"
@ -41,13 +41,13 @@ static const char rcsid[] = "$Id: inet_ntop.c 24646 2008-03-29 12:41:04Z bonefis
# define SPRINTF(x) ((size_t)sprintf x)
#endif
/*
/*%
* WARNING: Don't even consider trying to compile this on a system where
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
static const char *inet_ntop4 __P((const u_char *src, char *dst, socklen_t size));
static const char *inet_ntop6 __P((const u_char *src, char *dst, socklen_t size));
static const char *inet_ntop4 __P((const u_char *src, char *dst, size_t size));
static const char *inet_ntop6 __P((const u_char *src, char *dst, size_t size));
/* char *
* inet_ntop(af, src, dst, size)
@ -91,7 +91,7 @@ static const char *
inet_ntop4(src, dst, size)
const u_char *src;
char *dst;
socklen_t size;
size_t size;
{
static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"];
@ -114,7 +114,7 @@ static const char *
inet_ntop6(src, dst, size)
const u_char *src;
char *dst;
socklen_t size;
size_t size;
{
/*
* Note that int32_t and int16_t need only be "at least" large enough
@ -137,7 +137,9 @@ inet_ntop6(src, dst, size)
for (i = 0; i < NS_IN6ADDRSZ; i++)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1;
best.len = 0;
cur.base = -1;
cur.len = 0;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
if (words[i] == 0) {
if (cur.base == -1)
@ -186,7 +188,7 @@ inet_ntop6(src, dst, size)
tp += SPRINTF((tp, "%x", words[i]));
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) ==
if (best.base != -1 && (best.base + best.len) ==
(NS_IN6ADDRSZ / NS_INT16SZ))
*tp++ = ':';
*tp++ = '\0';
@ -194,7 +196,7 @@ inet_ntop6(src, dst, size)
/*
* Check for overflow, copy, and we're done.
*/
if ((socklen_t)(tp - tmp) > size) {
if ((size_t)(tp - tmp) > size) {
errno = ENOSPC;
return (NULL);
}
@ -202,5 +204,4 @@ inet_ntop6(src, dst, size)
return (dst);
}
#undef inet_ntop
#pragma weak inet_ntop=__inet_ntop
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_pton.c 24646 2008-03-29 12:41:04Z bonefish $";
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"
@ -30,7 +30,7 @@ static const char rcsid[] = "$Id: inet_pton.c 24646 2008-03-29 12:41:04Z bonefis
#include <errno.h>
#include "port_after.h"
/*
/*%
* WARNING: Don't even consider trying to compile this on a system where
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
*/
@ -141,7 +141,7 @@ inet_pton6(src, dst)
xdigits_u[] = "0123456789ABCDEF";
u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
const char *xdigits, *curtok;
int ch, saw_xdigit;
int ch, seen_xdigits;
u_int val;
memset((tp = tmp), '\0', NS_IN6ADDRSZ);
@ -152,7 +152,7 @@ inet_pton6(src, dst)
if (*++src != ':')
return (0);
curtok = src;
saw_xdigit = 0;
seen_xdigits = 0;
val = 0;
while ((ch = *src++) != '\0') {
const char *pch;
@ -162,14 +162,13 @@ inet_pton6(src, dst)
if (pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
if (val > 0xffff)
if (++seen_xdigits > 4)
return (0);
saw_xdigit = 1;
continue;
}
if (ch == ':') {
curtok = src;
if (!saw_xdigit) {
if (!seen_xdigits) {
if (colonp)
return (0);
colonp = tp;
@ -181,19 +180,19 @@ inet_pton6(src, dst)
return (0);
*tp++ = (u_char) (val >> 8) & 0xff;
*tp++ = (u_char) val & 0xff;
saw_xdigit = 0;
seen_xdigits = 0;
val = 0;
continue;
}
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
inet_pton4(curtok, tp) > 0) {
tp += NS_INADDRSZ;
saw_xdigit = 0;
break; /* '\0' was seen by inet_pton4(). */
seen_xdigits = 0;
break; /*%< '\\0' was seen by inet_pton4(). */
}
return (0);
}
if (saw_xdigit) {
if (seen_xdigits) {
if (tp + NS_INT16SZ > endp)
return (0);
*tp++ = (u_char) (val >> 8) & 0xff;
@ -221,5 +220,4 @@ inet_pton6(src, dst)
return (1);
}
#undef inet_pton
#pragma weak inet_pton=__inet_pton
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: nsap_addr.c 24646 2008-03-29 12:41:04Z bonefish $";
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"
@ -31,6 +31,7 @@ static const char rcsid[] = "$Id: nsap_addr.c 24646 2008-03-29 12:41:04Z bonefis
#include <ctype.h>
#include <resolv.h>
#include <resolv_mt.h>
#include "port_after.h"
@ -79,7 +80,7 @@ char *
inet_nsap_ntoa(int binlen, const u_char *binary, char *ascii) {
int nib;
int i;
static char tmpbuf[2+255*3];
char *tmpbuf = inet_nsap_ntoa_tmpbuf;
char *start;
if (ascii)
@ -107,7 +108,4 @@ inet_nsap_ntoa(int binlen, const u_char *binary, char *ascii) {
return (start);
}
#undef inet_nsap_addr
#undef inet_nsap_ntoa
#pragma weak inet_nsap_addr=__inet_nsap_addr
#pragma weak inet_nsap_ntoa=__inet_nsap_ntoa
/*! \file */

View File

@ -16,10 +16,11 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: dns.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: dns.c,v 1.5 2006/03/09 23:57:56 marka Exp $";
#endif
/*
/*! \file
* \brief
* dns.c --- this is the top-level accessor function for the dns
*/
@ -114,7 +115,7 @@ dns_res_get(struct irs_acc *this) {
res = (struct __res_state *)malloc(sizeof *res);
if (res == NULL)
return (NULL);
memset(dns->res, 0, sizeof *dns->res);
memset(res, 0, sizeof *res);
dns_res_set(this, res, free);
}

View File

@ -0,0 +1,294 @@
/*
* 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: dns_gr.c,v 1.4 2005/04/27 04:56:21 sra Exp $";
#endif
/*! \file
* \brief
* dns_gr.c --- this file contains the functions for accessing
* group information from Hesiod.
*/
#include "port_before.h"
#ifndef WANT_IRS_GR
static int __bind_irs_gr_unneeded;
#else
#include <sys/param.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "hesiod.h"
#include "dns_p.h"
/* Types. */
struct pvt {
/*
* This is our private accessor data. It has a shared hesiod context.
*/
struct dns_p * dns;
/*
* Need space to store the entries read from the group file.
* The members list also needs space per member, and the
* strings making up the user names must be allocated
* somewhere. Rather than doing lots of small allocations,
* we keep one buffer and resize it as needed.
*/
struct group group;
size_t nmemb; /*%< Malloc'd max index of gr_mem[]. */
char * membuf;
size_t membufsize;
};
/* Forward. */
static struct group * gr_next(struct irs_gr *);
static struct group * gr_byname(struct irs_gr *, const char *);
static struct group * gr_bygid(struct irs_gr *, gid_t);
static void gr_rewind(struct irs_gr *);
static void gr_close(struct irs_gr *);
static int gr_list(struct irs_gr *, const char *,
gid_t, gid_t *, int *);
static void gr_minimize(struct irs_gr *);
static struct __res_state * gr_res_get(struct irs_gr *);
static void gr_res_set(struct irs_gr *,
struct __res_state *,
void (*)(void *));
static struct group * get_hes_group(struct irs_gr *this,
const char *name,
const char *type);
/* Public. */
struct irs_gr *
irs_dns_gr(struct irs_acc *this) {
struct dns_p *dns = (struct dns_p *)this->private;
struct irs_gr *gr;
struct pvt *pvt;
if (!dns || !dns->hes_ctx) {
errno = ENODEV;
return (NULL);
}
if (!(pvt = memget(sizeof *pvt))) {
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
pvt->dns = dns;
if (!(gr = memget(sizeof *gr))) {
memput(pvt, sizeof *pvt);
errno = ENOMEM;
return (NULL);
}
memset(gr, 0x5e, sizeof *gr);
gr->private = pvt;
gr->next = gr_next;
gr->byname = gr_byname;
gr->bygid = gr_bygid;
gr->rewind = gr_rewind;
gr->close = gr_close;
gr->list = gr_list;
gr->minimize = gr_minimize;
gr->res_get = gr_res_get;
gr->res_set = gr_res_set;
return (gr);
}
/* methods */
static void
gr_close(struct irs_gr *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (pvt->group.gr_mem)
free(pvt->group.gr_mem);
if (pvt->membuf)
free(pvt->membuf);
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct group *
gr_next(struct irs_gr *this) {
UNUSED(this);
return (NULL);
}
static struct group *
gr_byname(struct irs_gr *this, const char *name) {
return (get_hes_group(this, name, "group"));
}
static struct group *
gr_bygid(struct irs_gr *this, gid_t gid) {
char name[32];
sprintf(name, "%ld", (long)gid);
return (get_hes_group(this, name, "gid"));
}
static void
gr_rewind(struct irs_gr *this) {
UNUSED(this);
/* NOOP */
}
static int
gr_list(struct irs_gr *this, const char *name,
gid_t basegid, gid_t *groups, int *ngroups)
{
UNUSED(this);
UNUSED(name);
UNUSED(basegid);
UNUSED(groups);
*ngroups = 0;
/* There's some way to do this in Hesiod. */
return (-1);
}
static void
gr_minimize(struct irs_gr *this) {
UNUSED(this);
/* NOOP */
}
/* Private. */
static struct group *
get_hes_group(struct irs_gr *this, const char *name, const char *type) {
struct pvt *pvt = (struct pvt *)this->private;
char **hes_list, *cp, **new;
size_t num_members = 0;
u_long t;
hes_list = hesiod_resolve(pvt->dns->hes_ctx, name, type);
if (!hes_list)
return (NULL);
/*
* Copy the returned hesiod string into storage space.
*/
if (pvt->membuf)
free(pvt->membuf);
pvt->membuf = strdup(*hes_list);
hesiod_free_list(pvt->dns->hes_ctx, hes_list);
cp = pvt->membuf;
pvt->group.gr_name = cp;
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
pvt->group.gr_passwd = cp;
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
errno = 0;
t = strtoul(cp, NULL, 10);
if (errno == ERANGE)
goto cleanup;
pvt->group.gr_gid = (gid_t) t;
if (!(cp = strchr(cp, ':')))
goto cleanup;
cp++;
/*
* Parse the members out.
*/
while (*cp) {
if (num_members+1 >= pvt->nmemb || pvt->group.gr_mem == NULL) {
pvt->nmemb += 10;
new = realloc(pvt->group.gr_mem,
pvt->nmemb * sizeof(char *));
if (new == NULL)
goto cleanup;
pvt->group.gr_mem = new;
}
pvt->group.gr_mem[num_members++] = cp;
if (!(cp = strchr(cp, ',')))
break;
*cp++ = '\0';
}
if (!pvt->group.gr_mem) {
pvt->group.gr_mem = malloc(sizeof(char*));
if (!pvt->group.gr_mem)
goto cleanup;
}
pvt->group.gr_mem[num_members] = NULL;
return (&pvt->group);
cleanup:
if (pvt->group.gr_mem) {
free(pvt->group.gr_mem);
pvt->group.gr_mem = NULL;
}
if (pvt->membuf) {
free(pvt->membuf);
pvt->membuf = NULL;
}
return (NULL);
}
static struct __res_state *
gr_res_get(struct irs_gr *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
return (__hesiod_res_get(dns->hes_ctx));
}
static void
gr_res_set(struct irs_gr *this, struct __res_state * res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
__hesiod_res_set(dns->hes_ctx, res, free_res);
}
#endif /* WANT_IRS_GR */

View File

@ -1,7 +1,24 @@
/*
* Portions Copyright (C) 2004-2006, 2008 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, 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
@ -31,28 +48,11 @@
* 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.
*/
/* from gethostnamadr.c 8.1 (Berkeley) 6/4/93 */
/* BIND Id: gethnamaddr.c,v 8.15 1996/05/22 04:56:30 vixie Exp $ */
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: dns_ho.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: dns_ho.c,v 1.23 2008/11/14 02:36:51 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/* Imports. */
@ -95,8 +95,7 @@ static const char rcsid[] = "$Id: dns_ho.c 15570 2005-12-16 22:38:13Z wkornew $"
#define MAXALIASES 35
#define MAXADDRS 35
#define MAXPACKET (65535) /* Maximum TCP message size */
#define MAXPACKET (65535) /*%< Maximum TCP message size */
#define BOUNDS_CHECK(ptr, count) \
if ((ptr) + (count) > eom) { \
had_error++; \
@ -110,14 +109,14 @@ typedef union {
struct dns_res_target {
struct dns_res_target *next;
querybuf qbuf; /* query buffer */
u_char *answer; /* buffer to put answer */
int anslen; /* size of answer buffer */
int qclass, qtype; /* class and type of query */
int action; /* condition whether query is really issued */
char qname[MAXDNAME +1]; /* domain name */
querybuf qbuf; /*%< query buffer */
u_char *answer; /*%< buffer to put answer */
int anslen; /*%< size of answer buffer */
int qclass, qtype; /*%< class and type of query */
int action; /*%< condition whether query is really issued */
char qname[MAXDNAME +1]; /*%< domain name */
#if 0
int n; /* result length */
int n; /*%< result length */
#endif
};
enum {RESTGT_DOALWAYS, RESTGT_AFTERFAILURE, RESTGT_IGNORE};
@ -128,7 +127,7 @@ struct pvt {
char * h_addr_ptrs[MAXADDRS + 1];
char * host_aliases[MAXALIASES];
char hostbuf[8*1024];
u_char host_addr[16]; /* IPv4 or IPv6 */
u_char host_addr[16]; /*%< IPv4 or IPv6 */
struct __res_state *res;
void (*free_res)(void *);
};
@ -141,8 +140,7 @@ typedef union {
static const u_char mapped[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0xff,0xff };
static const u_char tunnelled[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0,0 };
/* Note: the IPv6 loopback address is in the "tunnel" space */
static const u_char v6local[] = { 0,0, 0,1 }; /* last 4 bytes of IPv6 addr */
static const u_char v6local[] = { 0,0, 0,1 }; /*%< last 4 bytes of IPv6 addr */
/* Forwards. */
static void ho_close(struct irs_ho *this);
@ -218,8 +216,7 @@ ho_close(struct irs_ho *this) {
ho_minimize(this);
if (pvt->res && pvt->free_res)
(*pvt->free_res)(pvt->res);
if (pvt)
memput(pvt, sizeof *pvt);
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
@ -260,7 +257,7 @@ ho_byname2(struct irs_ho *this, const char *name, int af)
errno = ENOMEM;
goto cleanup;
}
memset(q, 0, sizeof(q));
memset(q, 0, sizeof(*q));
switch (af) {
case AF_INET:
@ -318,8 +315,7 @@ ho_byname2(struct irs_ho *this, const char *name, int af)
if ((hp = gethostans(this, p->answer, n, name, p->qtype,
af, size, NULL,
(const struct addrinfo *)&ai)) != NULL)
goto cleanup; /* no more loop is necessary */
goto cleanup; /*%< no more loop is necessary */
querystate = RESQRY_FAIL;
continue;
}
@ -341,7 +337,7 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
struct dns_res_target *q, *q2, *p;
int n, size, i;
int querystate = RESQRY_FAIL;
if (init(this) == -1)
return (NULL);
@ -352,13 +348,13 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
errno = ENOMEM;
goto cleanup;
}
memset(q, 0, sizeof(q));
memset(q2, 0, sizeof(q2));
memset(q, 0, sizeof(*q));
memset(q2, 0, sizeof(*q2));
if (af == AF_INET6 && len == IN6ADDRSZ &&
(!memcmp(uaddr, mapped, sizeof mapped) ||
(!memcmp(uaddr, tunnelled, sizeof tunnelled) &&
memcmp(&uaddr[sizeof tunnelled], v6local, sizeof(v6local))))) {
(!memcmp(uaddr, tunnelled, sizeof tunnelled) &&
memcmp(&uaddr[sizeof tunnelled], v6local, sizeof(v6local))))) {
/* Unmap. */
addr = (const char *)addr + sizeof mapped;
uaddr += sizeof mapped;
@ -484,7 +480,7 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
querystate = RESQRY_FAIL;
continue;
}
memcpy(pvt->host_addr, addr, len);
pvt->h_addr_ptrs[0] = (char *)pvt->host_addr;
pvt->h_addr_ptrs[1] = NULL;
@ -496,10 +492,9 @@ ho_byaddr(struct irs_ho *this, const void *addr, int len, int af)
}
RES_SET_H_ERRNO(pvt->res, NETDB_SUCCESS);
goto cleanup; /* no more loop is necessary. */
goto cleanup; /*%< no more loop is necessary. */
}
hp = NULL; /* H_ERRNO was set by subroutines */
hp = NULL; /*%< H_ERRNO was set by subroutines */
cleanup:
if (q != NULL)
memput(q, sizeof(*q));
@ -578,8 +573,8 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
errno = ENOMEM;
goto cleanup;
}
memset(q, 0, sizeof(q2));
memset(q2, 0, sizeof(q2));
memset(q, 0, sizeof(*q2));
memset(q2, 0, sizeof(*q2));
switch (pai->ai_family) {
case AF_UNSPEC:
@ -611,7 +606,7 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
q->action = RESTGT_DOALWAYS;
break;
default:
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY); /* better error? */
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY); /*%< better error? */
goto cleanup;
}
@ -644,15 +639,14 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
continue;
}
(void)gethostans(this, p->answer, n, name, p->qtype,
pai->ai_family, /* XXX: meaningless */
pai->ai_family, /*%< XXX: meaningless */
0, &ai, pai);
if (ai) {
querystate = RESQRY_SUCCESS;
cur->ai_next = ai;
while (cur && cur->ai_next)
while (cur->ai_next)
cur = cur->ai_next;
}
else
} else
querystate = RESQRY_FAIL;
}
@ -683,12 +677,12 @@ ho_res_set(struct irs_ho *this, struct __res_state *res,
static struct hostent *
gethostans(struct irs_ho *this,
const u_char *ansbuf, int anslen, const char *qname, int qtype,
int af, int size, /* meaningless for addrinfo cases */
int af, int size, /*!< meaningless for addrinfo cases */
struct addrinfo **ret_aip, const struct addrinfo *pai)
{
struct pvt *pvt = (struct pvt *)this->private;
int type, class, ancount, qdcount, n, haveanswer, had_error;
int error = NETDB_SUCCESS, arcount;
int error = NETDB_SUCCESS;
int (*name_ok)(const char *);
const HEADER *hp;
const u_char *eom;
@ -711,7 +705,7 @@ gethostans(struct irs_ho *this,
switch (qtype) {
case T_A:
case T_AAAA:
case T_ANY: /* use T_ANY only for T_A/T_AAAA lookup */
case T_ANY: /*%< use T_ANY only for T_A/T_AAAA lookup */
name_ok = res_hnok;
break;
case T_PTR:
@ -735,7 +729,6 @@ gethostans(struct irs_ho *this,
hp = (const HEADER *)ansbuf;
ancount = ntohs(hp->ancount);
qdcount = ntohs(hp->qdcount);
arcount = ntohs(hp->arcount);
bp = pvt->hostbuf;
ep = pvt->hostbuf + sizeof(pvt->hostbuf);
cp = ansbuf + HFIXEDSZ;
@ -758,7 +751,7 @@ gethostans(struct irs_ho *this,
* same as the one we sent; this just gets the expanded name
* (i.e., with the succeeding search-domain tacked on).
*/
n = strlen(bp) + 1; /* for the \0 */
n = strlen(bp) + 1; /*%< for the \\0 */
if (n > MAXHOSTNAMELEN) {
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
return (NULL);
@ -783,14 +776,14 @@ gethostans(struct irs_ho *this,
had_error++;
continue;
}
cp += n; /* name */
cp += n; /*%< name */
BOUNDS_CHECK(cp, 3 * INT16SZ + INT32SZ);
type = ns_get16(cp);
cp += INT16SZ; /* type */
cp += INT16SZ; /*%< type */
class = ns_get16(cp);
cp += INT16SZ + INT32SZ; /* class, TTL */
cp += INT16SZ + INT32SZ; /*%< class, TTL */
n = ns_get16(cp);
cp += INT16SZ; /* len */
cp += INT16SZ; /*%< len */
BOUNDS_CHECK(cp, n);
if (class != C_IN) {
cp += n;
@ -818,10 +811,10 @@ gethostans(struct irs_ho *this,
if (ap >= &pvt->host_aliases[MAXALIASES-1])
continue;
*ap++ = bp;
n = strlen(bp) + 1; /* for the \0 */
n = strlen(bp) + 1; /*%< for the \\0 */
bp += n;
/* Get canonical name. */
n = strlen(tbuf) + 1; /* for the \0 */
n = strlen(tbuf) + 1; /*%< for the \\0 */
if (n > (ep - bp) || n > MAXHOSTNAMELEN) {
had_error++;
continue;
@ -853,7 +846,7 @@ gethostans(struct irs_ho *this,
continue;
}
/* Get canonical name. */
n = strlen(tbuf) + 1; /* for the \0 */
n = strlen(tbuf) + 1; /*%< for the \\0 */
if (n > (ep - bp)) {
had_error++;
continue;
@ -899,7 +892,7 @@ gethostans(struct irs_ho *this,
else
n = -1;
if (n != -1) {
n = strlen(bp) + 1; /* for the \0 */
n = strlen(bp) + 1; /*%< for the \\0 */
bp += n;
}
break;
@ -930,7 +923,7 @@ gethostans(struct irs_ho *this,
if (!haveanswer) {
int nn;
nn = strlen(bp) + 1; /* for the \0 */
nn = strlen(bp) + 1; /*%< for the \\0 */
if (nn >= MAXHOSTNAMELEN) {
cp += n;
had_error++;
@ -944,14 +937,14 @@ gethostans(struct irs_ho *this,
bp = (char *)(((u_long)bp + (sizeof(align) - 1)) &
~(sizeof(align) - 1));
/* Avoid overflows. */
if (bp + n >= &pvt->hostbuf[sizeof pvt->hostbuf]) {
if (bp + n > &pvt->hostbuf[sizeof(pvt->hostbuf) - 1]) {
had_error++;
continue;
}
if (ret_aip) { /* need addrinfo. keep it. */
while (cur && cur->ai_next)
if (ret_aip) { /*%< need addrinfo. keep it. */
while (cur->ai_next)
cur = cur->ai_next;
} else if (cur->ai_next) { /* need hostent */
} else if (cur->ai_next) { /*%< need hostent */
struct addrinfo *aip = cur->ai_next;
for (aip = cur->ai_next; aip;
@ -965,7 +958,7 @@ gethostans(struct irs_ho *this,
}
if (m == 0)
continue;
if (hap < &pvt->h_addr_ptrs[MAXADDRS-1])
if (hap < &pvt->h_addr_ptrs[MAXADDRS])
hap++;
*hap = NULL;
bp += m;
@ -987,11 +980,12 @@ gethostans(struct irs_ho *this,
*ap = NULL;
*hap = NULL;
if (pvt->res->nsort && haveanswer > 1 && qtype == T_A)
if (pvt->res->nsort && hap != pvt->h_addr_ptrs &&
qtype == T_A)
addrsort(pvt->res, pvt->h_addr_ptrs,
haveanswer);
hap - pvt->h_addr_ptrs);
if (pvt->host.h_name == NULL) {
n = strlen(qname) + 1; /* for the \0 */
n = strlen(qname) + 1; /*%< for the \\0 */
if (n > (ep - bp) || n >= MAXHOSTNAMELEN)
goto no_recovery;
strcpy(bp, qname); /* (checked) */
@ -1047,18 +1041,17 @@ add_hostent(struct pvt *pvt, char *bp, char **hap, struct addrinfo *ai)
addrp = (char *)&((struct sockaddr_in *)ai->ai_addr)->sin_addr;
break;
default:
return(-1); /* abort? */
return(-1); /*%< abort? */
}
/* Ensure alignment. */
bp = (char *)(((u_long)bp + (sizeof(align) - 1)) &
~(sizeof(align) - 1));
/* Avoid overflows. */
if (bp + addrlen >= &pvt->hostbuf[sizeof pvt->hostbuf])
if (bp + addrlen > &pvt->hostbuf[sizeof(pvt->hostbuf) - 1])
return(-1);
if (hap >= &pvt->h_addr_ptrs[MAXADDRS-1])
return(0); /* fail, but not treat it as an error. */
if (hap >= &pvt->h_addr_ptrs[MAXADDRS])
return(0); /*%< fail, but not treat it as an error. */
/* Suppress duplicates. */
for (tap = (const char **)pvt->h_addr_ptrs;
*tap != NULL;
@ -1106,7 +1099,7 @@ addrsort(res_state statp, char **ap, int num) {
p = ap;
for (i = 0; i < num; i++, p++) {
for (j = 0 ; (unsigned)j < statp->nsort; j++)
if (statp->sort_list[j].addr.s_addr ==
if (statp->sort_list[j].addr.s_addr ==
(((struct in_addr *)(*p))->s_addr &
statp->sort_list[j].mask))
break;
@ -1140,7 +1133,7 @@ addrsort(res_state statp, char **ap, int num) {
static int
init(struct irs_ho *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (!pvt->res && !ho_res_get(this))
return (-1);
if (((pvt->res->options & RES_INIT) == 0U) &&

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: dns_nw.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: dns_nw.c,v 1.12 2005/04/27 04:56:22 sra Exp $";
#endif /* LIBC_SCCS and not lint */
/* Imports. */
@ -377,16 +377,16 @@ get1101answer(struct irs_nw *this,
while (--ancount >= 0 && cp < eom) {
int n = dn_expand(ansbuf, eom, cp, bp, ep - bp);
cp += n; /* Owner */
cp += n; /*%< Owner */
if (n < 0 || !maybe_dnok(pvt->res, bp) ||
cp + 3 * INT16SZ + INT32SZ > eom) {
RES_SET_H_ERRNO(pvt->res, NO_RECOVERY);
return (NULL);
}
GETSHORT(type, cp); /* Type */
GETSHORT(class, cp); /* Class */
cp += INT32SZ; /* TTL */
GETSHORT(n, cp); /* RDLENGTH */
GETSHORT(type, cp); /*%< Type */
GETSHORT(class, cp); /*%< Class */
cp += INT32SZ; /*%< TTL */
GETSHORT(n, cp); /*%< RDLENGTH */
if (class == C_IN && type == T_PTR) {
int nn;
@ -430,7 +430,7 @@ get1101answer(struct irs_nw *this,
}
}
}
cp += n; /* RDATA */
cp += n; /*%< RDATA */
}
if (!haveanswer) {
RES_SET_H_ERRNO(pvt->res, TRY_AGAIN);
@ -491,13 +491,13 @@ get1101mask(struct irs_nw *this, struct nwent *nwent) {
if (n < 0 || !maybe_dnok(pvt->res, owner))
break;
cp += n; /* Owner */
cp += n; /*%< Owner */
if (cp + 3 * INT16SZ + INT32SZ > eom)
break;
GETSHORT(type, cp); /* Type */
GETSHORT(class, cp); /* Class */
cp += INT32SZ; /* TTL */
GETSHORT(n, cp); /* RDLENGTH */
GETSHORT(type, cp); /*%< Type */
GETSHORT(class, cp); /*%< Class */
cp += INT32SZ; /*%< TTL */
GETSHORT(n, cp); /*%< RDLENGTH */
if (cp + n > eom)
break;
if (n == INADDRSZ && class == C_IN && type == T_A &&
@ -513,7 +513,7 @@ get1101mask(struct irs_nw *this, struct nwent *nwent) {
else
break;
}
cp += n; /* RDATA */
cp += n; /*%< RDATA */
}
memput(ansbuf, MAXPACKET);
return (nwent);
@ -587,3 +587,5 @@ init(struct irs_nw *this) {
return (-1);
return (0);
}
/*! \file */

View File

@ -16,7 +16,7 @@
*/
/*
* $Id: dns_p.h 15570 2005-12-16 22:38:13Z wkornew $
* $Id: dns_p.h,v 1.4 2005/04/27 04:56:22 sra Exp $
*/
#ifndef _DNS_P_H_INCLUDED
@ -27,7 +27,7 @@
#define maybe_hnok(res, hn) maybe_ok((res), (hn), res_hnok)
#define maybe_dnok(res, dn) maybe_ok((res), (dn), res_dnok)
/*
/*%
* Object state.
*/
struct dns_p {
@ -48,3 +48,5 @@ extern struct irs_ho * irs_dns_ho __P((struct irs_acc *));
extern struct irs_nw * irs_dns_nw __P((struct irs_acc *));
#endif /*_DNS_P_H_INCLUDED*/
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: dns_pr.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: dns_pr.c,v 1.5 2005/04/27 04:56:22 sra Exp $";
#endif
/* Imports */
@ -264,3 +264,5 @@ parse_hes_list(struct irs_pr *this, char **hes_list) {
}
return (NULL);
}
/*! \file */

View File

@ -0,0 +1,232 @@
/*
* 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: dns_pw.c,v 1.3 2005/04/27 04:56:22 sra Exp $";
#endif
#include "port_before.h"
#ifndef WANT_IRS_PW
static int __bind_irs_pw_unneeded;
#else
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "hesiod.h"
#include "dns_p.h"
/* Types. */
struct pvt {
struct dns_p * dns;
struct passwd passwd;
char * pwbuf;
};
/* Forward. */
static void pw_close(struct irs_pw *);
static struct passwd * pw_byname(struct irs_pw *, const char *);
static struct passwd * pw_byuid(struct irs_pw *, uid_t);
static struct passwd * pw_next(struct irs_pw *);
static void pw_rewind(struct irs_pw *);
static void pw_minimize(struct irs_pw *);
static struct __res_state * pw_res_get(struct irs_pw *);
static void pw_res_set(struct irs_pw *,
struct __res_state *,
void (*)(void *));
static struct passwd * getpwcommon(struct irs_pw *, const char *,
const char *);
/* Public. */
struct irs_pw *
irs_dns_pw(struct irs_acc *this) {
struct dns_p *dns = (struct dns_p *)this->private;
struct irs_pw *pw;
struct pvt *pvt;
if (!dns || !dns->hes_ctx) {
errno = ENODEV;
return (NULL);
}
if (!(pvt = memget(sizeof *pvt))) {
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
pvt->dns = dns;
if (!(pw = memget(sizeof *pw))) {
memput(pvt, sizeof *pvt);
errno = ENOMEM;
return (NULL);
}
memset(pw, 0x5e, sizeof *pw);
pw->private = pvt;
pw->close = pw_close;
pw->byname = pw_byname;
pw->byuid = pw_byuid;
pw->next = pw_next;
pw->rewind = pw_rewind;
pw->minimize = pw_minimize;
pw->res_get = pw_res_get;
pw->res_set = pw_res_set;
return (pw);
}
/* Methods. */
static void
pw_close(struct irs_pw *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (pvt->pwbuf)
free(pvt->pwbuf);
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct passwd *
pw_byname(struct irs_pw *this, const char *nam) {
return (getpwcommon(this, nam, "passwd"));
}
static struct passwd *
pw_byuid(struct irs_pw *this, uid_t uid) {
char uidstr[16];
sprintf(uidstr, "%lu", (u_long)uid);
return (getpwcommon(this, uidstr, "uid"));
}
static struct passwd *
pw_next(struct irs_pw *this) {
UNUSED(this);
errno = ENODEV;
return (NULL);
}
static void
pw_rewind(struct irs_pw *this) {
UNUSED(this);
/* NOOP */
}
static void
pw_minimize(struct irs_pw *this) {
UNUSED(this);
/* NOOP */
}
static struct __res_state *
pw_res_get(struct irs_pw *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
return (__hesiod_res_get(dns->hes_ctx));
}
static void
pw_res_set(struct irs_pw *this, struct __res_state * res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
struct dns_p *dns = pvt->dns;
__hesiod_res_set(dns->hes_ctx, res, free_res);
}
/* Private. */
static struct passwd *
getpwcommon(struct irs_pw *this, const char *arg, const char *type) {
struct pvt *pvt = (struct pvt *)this->private;
char **hes_list, *cp;
if (!(hes_list = hesiod_resolve(pvt->dns->hes_ctx, arg, type)))
return (NULL);
if (!*hes_list) {
hesiod_free_list(pvt->dns->hes_ctx, hes_list);
errno = ENOENT;
return (NULL);
}
memset(&pvt->passwd, 0, sizeof pvt->passwd);
if (pvt->pwbuf)
free(pvt->pwbuf);
pvt->pwbuf = strdup(*hes_list);
hesiod_free_list(pvt->dns->hes_ctx, hes_list);
cp = pvt->pwbuf;
pvt->passwd.pw_name = cp;
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
pvt->passwd.pw_passwd = cp;
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
pvt->passwd.pw_uid = atoi(cp);
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
pvt->passwd.pw_gid = atoi(cp);
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
pvt->passwd.pw_gecos = cp;
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
pvt->passwd.pw_dir = cp;
if (!(cp = strchr(cp, ':')))
goto cleanup;
*cp++ = '\0';
pvt->passwd.pw_shell = cp;
return (&pvt->passwd);
cleanup:
free(pvt->pwbuf);
pvt->pwbuf = NULL;
return (NULL);
}
#endif /* WANT_IRS_PW */
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: dns_sv.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: dns_sv.c,v 1.5 2005/04/27 04:56:23 sra Exp $";
#endif
/* Imports */
@ -111,8 +111,8 @@ irs_dns_sv(struct irs_acc *this) {
sv->res_get = sv_res_get;
sv->res_set = sv_res_set;
#else
sv->res_get = NULL; /* sv_res_get; */
sv->res_set = NULL; /* sv_res_set; */
sv->res_get = NULL; /*%< sv_res_get; */
sv->res_set = NULL; /*%< sv_res_set; */
#endif
return (sv);
}
@ -296,3 +296,5 @@ sv_res_set(struct irs_sv *this, struct __res_state * res,
__hesiod_res_set(dns->hes_ctx, res, free_res);
}
#endif
/*! \file */

View File

@ -20,38 +20,32 @@
#include <port_after.h>
#ifdef DO_PTHREADS
# include <OS.h>
# include <TLS.h>
# include <stdlib.h>
#include <pthread.h>
#include <stdlib.h>
#endif
static const char *gai_errlist[] = {
"no error",
"address family not supported for name",/* EAI_ADDRFAMILY */
"temporary failure", /* EAI_AGAIN */
"invalid flags", /* EAI_BADFLAGS */
"permanent failure", /* EAI_FAIL */
"address family not supported", /* EAI_FAMILY */
"memory failure", /* EAI_MEMORY */
"no address", /* EAI_NODATA */
"unknown name or service", /* EAI_NONAME */
"service not supported for socktype", /* EAI_SERVICE */
"socktype not supported", /* EAI_SOCKTYPE */
"system failure", /* EAI_SYSTEM */
"bad hints", /* EAI_BADHINTS */
"bad protocol", /* EAI_PROTOCOL */
"unknown error" /* Must be last. */
"address family not supported for name",/*%< EAI_ADDRFAMILY */
"temporary failure", /*%< EAI_AGAIN */
"invalid flags", /*%< EAI_BADFLAGS */
"permanent failure", /*%< EAI_FAIL */
"address family not supported", /*%< EAI_FAMILY */
"memory failure", /*%< EAI_MEMORY */
"no address", /*%< EAI_NODATA */
"unknown name or service", /*%< EAI_NONAME */
"service not supported for socktype", /*%< EAI_SERVICE */
"socktype not supported", /*%< EAI_SOCKTYPE */
"system failure", /*%< EAI_SYSTEM */
"bad hints", /*%< EAI_BADHINTS */
"bad protocol", /*%< EAI_PROTOCOL */
"unknown error" /*%< Must be last. */
};
static const int gai_nerr = (sizeof(gai_errlist)/sizeof(*gai_errlist));
#define EAI_BUFSIZE 128
#ifdef DO_PTHREADS
int32 gGaiStrerrorKey;
#endif
const char *
gai_strerror(int ecode) {
#ifndef DO_PTHREADS
@ -60,20 +54,39 @@ gai_strerror(int ecode) {
#ifndef LIBBIND_MUTEX_INITIALIZER
#define LIBBIND_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#endif
static pthread_mutex_t lock = LIBBIND_MUTEX_INITIALIZER;
static pthread_key_t key;
static int once = 0;
char *buf;
#endif
if (ecode >= 0 && ecode < (gai_nerr - 1))
return (gai_errlist[ecode]);
#ifdef DO_PTHREADS
buf = tls_get(gGaiStrerrorKey);
if (!once) {
if (pthread_mutex_lock(&lock) != 0)
goto unknown;
if (!once) {
if (pthread_key_create(&key, free) != 0) {
(void)pthread_mutex_unlock(&lock);
goto unknown;
}
once = 1;
}
if (pthread_mutex_unlock(&lock) != 0)
goto unknown;
}
buf = pthread_getspecific(key);
if (buf == NULL) {
buf = malloc(EAI_BUFSIZE);
if (buf == NULL)
return ("unknown error");
on_exit_thread(free, buf);
tls_set(gGaiStrerrorKey, buf);
goto unknown;
if (pthread_setspecific(key, buf) != 0) {
free(buf);
goto unknown;
}
}
#endif
/*
@ -82,4 +95,11 @@ gai_strerror(int ecode) {
*/
sprintf(buf, "%s: %d", gai_errlist[gai_nerr - 1], ecode);
return (buf);
#ifdef DO_PTHREADS
unknown:
return ("unknown error");
#endif
}
/*! \file */

View File

@ -16,10 +16,11 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gen.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: gen.c,v 1.7 2005/04/27 04:56:23 sra Exp $";
#endif
/*
/*! \file
* \brief
* this is the top level dispatcher
*
* The dispatcher is implemented as an accessor class; it is an

View File

@ -0,0 +1,493 @@
/*
* 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.
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gen_gr.c,v 1.8 2005/04/27 04:56:23 sra Exp $";
#endif
/* Imports */
#include "port_before.h"
#ifndef WANT_IRS_GR
static int __bind_irs_gr_unneeded;
#else
#include <sys/types.h>
#include <isc/assertions.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "gen_p.h"
/* Definitions */
struct pvt {
struct irs_rule * rules;
struct irs_rule * rule;
struct irs_gr * gr;
/*
* Need space to store the entries read from the group file.
* The members list also needs space per member, and the
* strings making up the user names must be allocated
* somewhere. Rather than doing lots of small allocations,
* we keep one buffer and resize it as needed.
*/
struct group group;
size_t nmemb; /*%< Malloc'd max index of gr_mem[]. */
char * membuf;
size_t membufsize;
struct __res_state * res;
void (*free_res)(void *);
};
/* Forward */
static void gr_close(struct irs_gr *);
static struct group * gr_next(struct irs_gr *);
static struct group * gr_byname(struct irs_gr *, const char *);
static struct group * gr_bygid(struct irs_gr *, gid_t);
static void gr_rewind(struct irs_gr *);
static int gr_list(struct irs_gr *, const char *,
gid_t, gid_t *, int *);
static void gr_minimize(struct irs_gr *);
static struct __res_state * gr_res_get(struct irs_gr *);
static void gr_res_set(struct irs_gr *,
struct __res_state *,
void (*)(void *));
static int grmerge(struct irs_gr *gr, const struct group *src,
int preserve);
static int countvec(char **vec);
static int isnew(char **old, char *new);
static int countnew(char **old, char **new);
static size_t sizenew(char **old, char **new);
static int newgid(int, gid_t *, gid_t);
/* Macros */
#define FREE_IF(x) do { if ((x) != NULL) { free(x); (x) = NULL; } } while (0)
/* Public */
struct irs_gr *
irs_gen_gr(struct irs_acc *this) {
struct gen_p *accpvt = (struct gen_p *)this->private;
struct irs_gr *gr;
struct pvt *pvt;
if (!(gr = memget(sizeof *gr))) {
errno = ENOMEM;
return (NULL);
}
memset(gr, 0x5e, sizeof *gr);
if (!(pvt = memget(sizeof *pvt))) {
memput(gr, sizeof *gr);
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
pvt->rules = accpvt->map_rules[irs_gr];
pvt->rule = pvt->rules;
gr->private = pvt;
gr->close = gr_close;
gr->next = gr_next;
gr->byname = gr_byname;
gr->bygid = gr_bygid;
gr->rewind = gr_rewind;
gr->list = gr_list;
gr->minimize = gr_minimize;
gr->res_get = gr_res_get;
gr->res_set = gr_res_set;
return (gr);
}
/* Methods. */
static void
gr_close(struct irs_gr *this) {
struct pvt *pvt = (struct pvt *)this->private;
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct group *
gr_next(struct irs_gr *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct group *rval;
struct irs_gr *gr;
while (pvt->rule) {
gr = pvt->rule->inst->gr;
rval = (*gr->next)(gr);
if (rval)
return (rval);
if (!(pvt->rule->flags & IRS_CONTINUE))
break;
pvt->rule = pvt->rule->next;
if (pvt->rule) {
gr = pvt->rule->inst->gr;
(*gr->rewind)(gr);
}
}
return (NULL);
}
static struct group *
gr_byname(struct irs_gr *this, const char *name) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct group *tval;
struct irs_gr *gr;
int dirty;
dirty = 0;
for (rule = pvt->rules; rule; rule = rule->next) {
gr = rule->inst->gr;
tval = (*gr->byname)(gr, name);
if (tval) {
if (!grmerge(this, tval, dirty++))
return (NULL);
if (!(rule->flags & IRS_MERGE))
break;
} else {
if (!(rule->flags & IRS_CONTINUE))
break;
}
}
if (dirty)
return (&pvt->group);
return (NULL);
}
static struct group *
gr_bygid(struct irs_gr *this, gid_t gid) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct group *tval;
struct irs_gr *gr;
int dirty;
dirty = 0;
for (rule = pvt->rules; rule; rule = rule->next) {
gr = rule->inst->gr;
tval = (*gr->bygid)(gr, gid);
if (tval) {
if (!grmerge(this, tval, dirty++))
return (NULL);
if (!(rule->flags & IRS_MERGE))
break;
} else {
if (!(rule->flags & IRS_CONTINUE))
break;
}
}
if (dirty)
return (&pvt->group);
return (NULL);
}
static void
gr_rewind(struct irs_gr *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_gr *gr;
pvt->rule = pvt->rules;
if (pvt->rule) {
gr = pvt->rule->inst->gr;
(*gr->rewind)(gr);
}
}
static int
gr_list(struct irs_gr *this, const char *name,
gid_t basegid, gid_t *groups, int *ngroups)
{
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct irs_gr *gr;
int t_ngroups, maxgroups;
gid_t *t_groups;
int n, t, rval = 0;
maxgroups = *ngroups;
*ngroups = 0;
t_groups = (gid_t *)malloc(maxgroups * sizeof(gid_t));
if (!t_groups) {
errno = ENOMEM;
return (-1);
}
for (rule = pvt->rules; rule; rule = rule->next) {
t_ngroups = maxgroups;
gr = rule->inst->gr;
t = (*gr->list)(gr, name, basegid, t_groups, &t_ngroups);
for (n = 0; n < t_ngroups; n++) {
if (newgid(*ngroups, groups, t_groups[n])) {
if (*ngroups == maxgroups) {
rval = -1;
goto done;
}
groups[(*ngroups)++] = t_groups[n];
}
}
if (t == 0) {
if (!(rule->flags & IRS_MERGE))
break;
} else {
if (!(rule->flags & IRS_CONTINUE))
break;
}
}
done:
free(t_groups);
return (rval);
}
static void
gr_minimize(struct irs_gr *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_gr *gr = rule->inst->gr;
(*gr->minimize)(gr);
}
}
static struct __res_state *
gr_res_get(struct irs_gr *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (!pvt->res) {
struct __res_state *res;
res = (struct __res_state *)malloc(sizeof *res);
if (!res) {
errno = ENOMEM;
return (NULL);
}
memset(res, 0, sizeof *res);
gr_res_set(this, res, free);
}
return (pvt->res);
}
static void
gr_res_set(struct irs_gr *this, struct __res_state *res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
if (pvt->res && pvt->free_res) {
res_nclose(pvt->res);
(*pvt->free_res)(pvt->res);
}
pvt->res = res;
pvt->free_res = free_res;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_gr *gr = rule->inst->gr;
if (gr->res_set)
(*gr->res_set)(gr, pvt->res, NULL);
}
}
/* Private. */
static int
grmerge(struct irs_gr *this, const struct group *src, int preserve) {
struct pvt *pvt = (struct pvt *)this->private;
char *cp, **m, **p, *oldmembuf, *ep;
int n, ndst, nnew;
size_t used;
if (!preserve) {
pvt->group.gr_gid = src->gr_gid;
if (pvt->nmemb < 1) {
m = malloc(sizeof *m);
if (m == NULL) {
/* No harm done, no work done. */
return (0);
}
pvt->group.gr_mem = m;
pvt->nmemb = 1;
}
pvt->group.gr_mem[0] = NULL;
}
ndst = countvec(pvt->group.gr_mem);
nnew = countnew(pvt->group.gr_mem, src->gr_mem);
/*
* Make sure destination member array is large enough.
* p points to new portion.
*/
n = ndst + nnew + 1;
if ((size_t)n > pvt->nmemb) {
m = realloc(pvt->group.gr_mem, n * sizeof *m);
if (m == NULL) {
/* No harm done, no work done. */
return (0);
}
pvt->group.gr_mem = m;
pvt->nmemb = n;
}
p = pvt->group.gr_mem + ndst;
/*
* Enlarge destination membuf; cp points at new portion.
*/
n = sizenew(pvt->group.gr_mem, src->gr_mem);
INSIST((nnew == 0) == (n == 0));
if (!preserve) {
n += strlen(src->gr_name) + 1;
n += strlen(src->gr_passwd) + 1;
}
if (n == 0) {
/* No work to do. */
return (1);
}
used = preserve ? pvt->membufsize : 0;
cp = malloc(used + n);
if (cp == NULL) {
/* No harm done, no work done. */
return (0);
}
ep = cp + used + n;
if (used != 0)
memcpy(cp, pvt->membuf, used);
oldmembuf = pvt->membuf;
pvt->membuf = cp;
pvt->membufsize = used + n;
cp += used;
/*
* Adjust group.gr_mem.
*/
if (pvt->membuf != oldmembuf)
for (m = pvt->group.gr_mem; *m; m++)
*m = pvt->membuf + (*m - oldmembuf);
/*
* Add new elements.
*/
for (m = src->gr_mem; *m; m++)
if (isnew(pvt->group.gr_mem, *m)) {
*p++ = cp;
*p = NULL;
n = strlen(*m) + 1;
if (n > ep - cp) {
FREE_IF(oldmembuf);
return (0);
}
strcpy(cp, *m); /* (checked) */
cp += n;
}
if (preserve) {
pvt->group.gr_name = pvt->membuf +
(pvt->group.gr_name - oldmembuf);
pvt->group.gr_passwd = pvt->membuf +
(pvt->group.gr_passwd - oldmembuf);
} else {
pvt->group.gr_name = cp;
n = strlen(src->gr_name) + 1;
if (n > ep - cp) {
FREE_IF(oldmembuf);
return (0);
}
strcpy(cp, src->gr_name); /* (checked) */
cp += n;
pvt->group.gr_passwd = cp;
n = strlen(src->gr_passwd) + 1;
if (n > ep - cp) {
FREE_IF(oldmembuf);
return (0);
}
strcpy(cp, src->gr_passwd); /* (checked) */
cp += n;
}
FREE_IF(oldmembuf);
INSIST(cp >= pvt->membuf && cp <= &pvt->membuf[pvt->membufsize]);
return (1);
}
static int
countvec(char **vec) {
int n = 0;
while (*vec++)
n++;
return (n);
}
static int
isnew(char **old, char *new) {
for (; *old; old++)
if (strcmp(*old, new) == 0)
return (0);
return (1);
}
static int
countnew(char **old, char **new) {
int n = 0;
for (; *new; new++)
n += isnew(old, *new);
return (n);
}
static size_t
sizenew(char **old, char **new) {
size_t n = 0;
for (; *new; new++)
if (isnew(old, *new))
n += strlen(*new) + 1;
return (n);
}
static int
newgid(int ngroups, gid_t *groups, gid_t group) {
ngroups--, groups++;
for (; ngroups-- > 0; groups++)
if (*groups == group)
return (0);
return (1);
}
#endif /* WANT_IRS_GR */
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: gen_ho.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: gen_ho.c,v 1.5 2006/03/09 23:57:56 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/* Imports */
@ -348,7 +348,7 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
ho = rule->inst->ho;
RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL);
errno = 0;
if (ho->addrinfo == NULL) /* for safety */
if (ho->addrinfo == NULL) /*%< for safety */
continue;
rval = (*ho->addrinfo)(ho, name, pai);
if (rval != NULL)
@ -371,8 +371,6 @@ ho_addrinfo(struct irs_ho *this, const char *name, const struct addrinfo *pai)
}
if (softerror != 0 && pvt->res->res_h_errno == HOST_NOT_FOUND)
RES_SET_H_ERRNO(pvt->res, therrno);
if (rval)
freeaddrinfo(rval);
return (NULL);
}
@ -389,3 +387,5 @@ init(struct irs_ho *this) {
return (0);
}
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gen_ng.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: gen_ng.c,v 1.3 2005/04/27 04:56:23 sra Exp $";
#endif
/* Imports */
@ -170,3 +170,5 @@ ng_minimize(struct irs_ng *this) {
(*ng->minimize)(ng);
}
}
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gen_nw.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: gen_nw.c,v 1.4 2005/04/27 04:56:23 sra Exp $";
#endif
/* Imports */
@ -260,3 +260,5 @@ init(struct irs_nw *this) {
return (-1);
return (0);
}
/*! \file */

View File

@ -16,10 +16,11 @@
*/
/*
* $Id: gen_p.h 15570 2005-12-16 22:38:13Z wkornew $
* $Id: gen_p.h,v 1.3 2005/04/27 04:56:23 sra Exp $
*/
/* Notes:
/*! \file
* Notes:
* We hope to create a complete set of thread-safe entry points someday,
* which will mean a set of getXbyY() functions that take as an argument
* a pointer to the map class, which will have a pointer to the private
@ -36,32 +37,32 @@
#ifndef _GEN_P_H_INCLUDED
#define _GEN_P_H_INCLUDED
/*
/*%
* These are the access methods.
*/
enum irs_acc_id {
irs_lcl, /* Local. */
irs_dns, /* DNS or Hesiod. */
irs_nis, /* Sun NIS ("YP"). */
irs_irp, /* IR protocol. */
irs_lcl, /*%< Local. */
irs_dns, /*%< DNS or Hesiod. */
irs_nis, /*%< Sun NIS ("YP"). */
irs_irp, /*%< IR protocol. */
irs_nacc
};
/*
/*%
* These are the map types.
*/
enum irs_map_id {
irs_gr, /* "group" */
irs_pw, /* "passwd" */
irs_sv, /* "services" */
irs_pr, /* "protocols" */
irs_ho, /* "hosts" */
irs_nw, /* "networks" */
irs_ng, /* "netgroup" */
irs_gr, /*%< "group" */
irs_pw, /*%< "passwd" */
irs_sv, /*%< "services" */
irs_pr, /*%< "protocols" */
irs_ho, /*%< "hosts" */
irs_nw, /*%< "networks" */
irs_ng, /*%< "netgroup" */
irs_nmap
};
/*
/*%
* This is an accessor instance.
*/
struct irs_inst {
@ -75,7 +76,7 @@ struct irs_inst {
struct irs_ng * ng;
};
/*
/*%
* This is a search rule for some map type.
*/
struct irs_rule {
@ -83,9 +84,8 @@ struct irs_rule {
struct irs_inst * inst;
int flags;
};
#define IRS_MERGE 0x0001 /* Don't stop if acc. has data? */
#define IRS_CONTINUE 0x0002 /* Don't stop if acc. has no data? */
#define IRS_MERGE 0x0001 /*%< Don't stop if acc. has data? */
#define IRS_CONTINUE 0x0002 /*%< Don't stop if acc. has no data? */
/*
* This is the private data for a search access class.
*/

View File

@ -16,7 +16,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gen_pr.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: gen_pr.c,v 1.3 2005/04/27 04:56:24 sra Exp $";
#endif
/* Imports */
@ -224,3 +224,5 @@ pr_res_set(struct irs_pr *this, struct __res_state *res,
(*pr->res_set)(pr, pvt->res, NULL);
}
}
/*! \file */

View File

@ -0,0 +1,234 @@
/*
* 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.
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gen_pw.c,v 1.3 2005/04/27 04:56:24 sra Exp $";
#endif
/* Imports */
#include "port_before.h"
#ifndef WANT_IRS_PW
static int __bind_irs_pw_unneeded;
#else
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <errno.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
#include <isc/memcluster.h>
#include <irs.h>
#include "port_after.h"
#include "irs_p.h"
#include "gen_p.h"
/* Types */
struct pvt {
struct irs_rule * rules;
struct irs_rule * rule;
struct __res_state * res;
void (*free_res)(void *);
};
/* Forward */
static void pw_close(struct irs_pw *);
static struct passwd * pw_next(struct irs_pw *);
static struct passwd * pw_byname(struct irs_pw *, const char *);
static struct passwd * pw_byuid(struct irs_pw *, uid_t);
static void pw_rewind(struct irs_pw *);
static void pw_minimize(struct irs_pw *);
static struct __res_state * pw_res_get(struct irs_pw *);
static void pw_res_set(struct irs_pw *,
struct __res_state *,
void (*)(void *));
/* Public */
struct irs_pw *
irs_gen_pw(struct irs_acc *this) {
struct gen_p *accpvt = (struct gen_p *)this->private;
struct irs_pw *pw;
struct pvt *pvt;
if (!(pw = memget(sizeof *pw))) {
errno = ENOMEM;
return (NULL);
}
memset(pw, 0x5e, sizeof *pw);
if (!(pvt = memget(sizeof *pvt))) {
memput(pw, sizeof *pvt);
errno = ENOMEM;
return (NULL);
}
memset(pvt, 0, sizeof *pvt);
pvt->rules = accpvt->map_rules[irs_pw];
pvt->rule = pvt->rules;
pw->private = pvt;
pw->close = pw_close;
pw->next = pw_next;
pw->byname = pw_byname;
pw->byuid = pw_byuid;
pw->rewind = pw_rewind;
pw->minimize = pw_minimize;
pw->res_get = pw_res_get;
pw->res_set = pw_res_set;
return (pw);
}
/* Methods */
static void
pw_close(struct irs_pw *this) {
struct pvt *pvt = (struct pvt *)this->private;
memput(pvt, sizeof *pvt);
memput(this, sizeof *this);
}
static struct passwd *
pw_next(struct irs_pw *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct passwd *rval;
struct irs_pw *pw;
while (pvt->rule) {
pw = pvt->rule->inst->pw;
rval = (*pw->next)(pw);
if (rval)
return (rval);
if (!(pvt->rule->flags & IRS_CONTINUE))
break;
pvt->rule = pvt->rule->next;
if (pvt->rule) {
pw = pvt->rule->inst->pw;
(*pw->rewind)(pw);
}
}
return (NULL);
}
static void
pw_rewind(struct irs_pw *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_pw *pw;
pvt->rule = pvt->rules;
if (pvt->rule) {
pw = pvt->rule->inst->pw;
(*pw->rewind)(pw);
}
}
static struct passwd *
pw_byname(struct irs_pw *this, const char *name) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct passwd *rval;
struct irs_pw *pw;
rval = NULL;
for (rule = pvt->rules; rule; rule = rule->next) {
pw = rule->inst->pw;
rval = (*pw->byname)(pw, name);
if (rval || !(rule->flags & IRS_CONTINUE))
break;
}
return (rval);
}
static struct passwd *
pw_byuid(struct irs_pw *this, uid_t uid) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
struct passwd *rval;
struct irs_pw *pw;
rval = NULL;
for (rule = pvt->rules; rule; rule = rule->next) {
pw = rule->inst->pw;
rval = (*pw->byuid)(pw, uid);
if (rval || !(rule->flags & IRS_CONTINUE))
break;
}
return (rval);
}
static void
pw_minimize(struct irs_pw *this) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_pw *pw = rule->inst->pw;
(*pw->minimize)(pw);
}
}
static struct __res_state *
pw_res_get(struct irs_pw *this) {
struct pvt *pvt = (struct pvt *)this->private;
if (!pvt->res) {
struct __res_state *res;
res = (struct __res_state *)malloc(sizeof *res);
if (!res) {
errno = ENOMEM;
return (NULL);
}
memset(res, 0, sizeof *res);
pw_res_set(this, res, free);
}
return (pvt->res);
}
static void
pw_res_set(struct irs_pw *this, struct __res_state *res,
void (*free_res)(void *)) {
struct pvt *pvt = (struct pvt *)this->private;
struct irs_rule *rule;
if (pvt->res && pvt->free_res) {
res_nclose(pvt->res);
(*pvt->free_res)(pvt->res);
}
pvt->res = res;
pvt->free_res = free_res;
for (rule = pvt->rules; rule != NULL; rule = rule->next) {
struct irs_pw *pw = rule->inst->pw;
if (pw->res_set)
(*pw->res_set)(pw, pvt->res, NULL);
}
}
#endif /* WANT_IRS_PW */
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gen_sv.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: gen_sv.c,v 1.3 2005/04/27 04:56:24 sra Exp $";
#endif
/* Imports */
@ -225,3 +225,5 @@ sv_res_set(struct irs_sv *this, struct __res_state *res,
(*sv->res_set)(sv, pvt->res, NULL);
}
}
/*! \file */

View File

@ -29,48 +29,52 @@
* SUCH DAMAGE.
*/
/*
/*! \file
* Issues to be discussed:
* - Thread safe-ness must be checked.
* - Return values. There are nonstandard return values defined and used
*\li Thread safe-ness must be checked.
*\li Return values. There are nonstandard return values defined and used
* in the source code. This is because RFC2553 is silent about which error
* code must be returned for which situation.
* - IPv4 classful (shortened) form. RFC2553 is silent about it. XNET 5.2
*\li IPv4 classful (shortened) form. RFC2553 is silent about it. XNET 5.2
* says to use inet_aton() to convert IPv4 numeric to binary (allows
* classful form as a result).
* current code - disallow classful form for IPv4 (due to use of inet_pton).
* - freeaddrinfo(NULL). RFC2553 is silent about it. XNET 5.2 says it is
*\li freeaddrinfo(NULL). RFC2553 is silent about it. XNET 5.2 says it is
* invalid.
* current code - SEGV on freeaddrinfo(NULL)
* Note:
* - We use getipnodebyname() just for thread-safeness. There's no intent
*\li We use getipnodebyname() just for thread-safeness. There's no intent
* to let it do PF_UNSPEC (actually we never pass PF_UNSPEC to
* getipnodebyname().
* - The code filters out AFs that are not supported by the kernel,
*\li The code filters out AFs that are not supported by the kernel,
* when globbing NULL hostname (to loopback, or wildcard). Is it the right
* thing to do? What is the relationship with post-RFC2553 AI_ADDRCONFIG
* in ai_flags?
* - (post-2553) semantics of AI_ADDRCONFIG itself is too vague.
*\li (post-2553) semantics of AI_ADDRCONFIG itself is too vague.
* (1) what should we do against numeric hostname (2) what should we do
* against NULL hostname (3) what is AI_ADDRCONFIG itself. AF not ready?
* non-loopback address configured? global address configured?
* - To avoid search order issue, we have a big amount of code duplicate
* \par Additional Issue:
* To avoid search order issue, we have a big amount of code duplicate
* from gethnamaddr.c and some other places. The issues that there's no
* lower layer function to lookup "IPv4 or IPv6" record. Calling
* gethostbyname2 from getaddrinfo will end up in wrong search order, as
* follows:
* - The code makes use of following calls when asked to resolver with
* \li The code makes use of following calls when asked to resolver with
* ai_family = PF_UNSPEC:
* getipnodebyname(host, AF_INET6);
*\code getipnodebyname(host, AF_INET6);
* getipnodebyname(host, AF_INET);
* This will result in the following queries if the node is configure to
*\endcode
* \li This will result in the following queries if the node is configure to
* prefer /etc/hosts than DNS:
*\code
* lookup /etc/hosts for IPv6 address
* lookup DNS for IPv6 address
* lookup /etc/hosts for IPv4 address
* lookup DNS for IPv4 address
*\endcode
* which may not meet people's requirement.
* The right thing to happen is to have underlying layer which does
* \li The right thing to happen is to have underlying layer which does
* PF_UNSPEC lookup (lookup both) and return chain of addrinfos.
* This would result in a bit of code duplicate with _dns_ghbyname() and
* friends.
@ -199,20 +203,20 @@ struct addrinfo *addr2addrinfo __P((const struct addrinfo *,
#if 0
static const char *ai_errlist[] = {
"Success",
"Address family for hostname not supported", /* EAI_ADDRFAMILY */
"Temporary failure in name resolution", /* EAI_AGAIN */
"Invalid value for ai_flags", /* EAI_BADFLAGS */
"Non-recoverable failure in name resolution", /* EAI_FAIL */
"ai_family not supported", /* EAI_FAMILY */
"Memory allocation failure", /* EAI_MEMORY */
"No address associated with hostname", /* EAI_NODATA */
"hostname nor servname provided, or not known", /* EAI_NONAME */
"servname not supported for ai_socktype", /* EAI_SERVICE */
"ai_socktype not supported", /* EAI_SOCKTYPE */
"System error returned in errno", /* EAI_SYSTEM */
"Invalid value for hints", /* EAI_BADHINTS */
"Resolved protocol is unknown", /* EAI_PROTOCOL */
"Unknown error", /* EAI_MAX */
"Address family for hostname not supported", /*%< EAI_ADDRFAMILY */
"Temporary failure in name resolution", /*%< EAI_AGAIN */
"Invalid value for ai_flags", /*%< EAI_BADFLAGS */
"Non-recoverable failure in name resolution", /*%< EAI_FAIL */
"ai_family not supported", /*%< EAI_FAMILY */
"Memory allocation failure", /*%< EAI_MEMORY */
"No address associated with hostname", /*%< EAI_NODATA */
"hostname nor servname provided, or not known", /*%< EAI_NONAME */
"servname not supported for ai_socktype", /*%< EAI_SERVICE */
"ai_socktype not supported", /*%< EAI_SOCKTYPE */
"System error returned in errno", /*%< EAI_SYSTEM */
"Invalid value for hints", /*%< EAI_BADHINTS */
"Resolved protocol is unknown", /*%< EAI_PROTOCOL */
"Unknown error", /*%< EAI_MAX */
};
#endif
@ -244,20 +248,31 @@ do { \
goto free; \
} while (/*CONSTCOND*/0)
#define ERR(err) \
#ifndef SOLARIS2
#define SETERROR(err) \
do { \
/* external reference: error, and label bad */ \
error = (err); \
goto bad; \
/*NOTREACHED*/ \
} while (/*CONSTCOND*/0)
#else
#define SETERROR(err) \
do { \
/* external reference: error, and label bad */ \
error = (err); \
if (error == error) \
goto bad; \
} while (/*CONSTCOND*/0)
#endif
#define MATCH_FAMILY(x, y, w) \
((x) == (y) || (/*CONSTCOND*/(w) && ((x) == PF_UNSPEC || (y) == PF_UNSPEC)))
#define MATCH(x, y, w) \
((x) == (y) || (/*CONSTCOND*/(w) && ((x) == ANY || (y) == ANY)))
#if 0 /* bind8 has its own version */
#if 0 /*%< bind8 has its own version */
char *
gai_strerror(ecode)
int ecode;
@ -321,6 +336,15 @@ getaddrinfo(hostname, servname, hints, res)
pai->ai_family = PF_UNSPEC;
pai->ai_socktype = ANY;
pai->ai_protocol = ANY;
#if defined(sun) && defined(_SOCKLEN_T) && defined(__sparcv9)
/*
* clear _ai_pad to preserve binary
* compatibility with previously compiled 64-bit
* applications in a pre-SUSv3 environment by
* guaranteeing the upper 32-bits are empty.
*/
pai->_ai_pad = 0;
#endif
pai->ai_addrlen = 0;
pai->ai_canonname = NULL;
pai->ai_addr = NULL;
@ -332,19 +356,26 @@ getaddrinfo(hostname, servname, hints, res)
/* error check for hints */
if (hints->ai_addrlen || hints->ai_canonname ||
hints->ai_addr || hints->ai_next)
ERR(EAI_BADHINTS); /* xxx */
SETERROR(EAI_BADHINTS); /*%< xxx */
if (hints->ai_flags & ~AI_MASK)
ERR(EAI_BADFLAGS);
SETERROR(EAI_BADFLAGS);
switch (hints->ai_family) {
case PF_UNSPEC:
case PF_INET:
case PF_INET6:
break;
default:
ERR(EAI_FAMILY);
SETERROR(EAI_FAMILY);
}
memcpy(pai, hints, sizeof(*pai));
#if defined(sun) && defined(_SOCKLEN_T) && defined(__sparcv9)
/*
* We need to clear _ai_pad to preserve binary
* compatibility. See prior comment.
*/
pai->_ai_pad = 0;
#endif
/*
* if both socktype/protocol are specified, check if they
* are meaningful combination.
@ -359,7 +390,7 @@ getaddrinfo(hostname, servname, hints, res)
continue;
if (pai->ai_socktype == ex->e_socktype &&
pai->ai_protocol != ex->e_protocol) {
ERR(EAI_BADHINTS);
SETERROR(EAI_BADHINTS);
}
}
}
@ -379,7 +410,7 @@ getaddrinfo(hostname, servname, hints, res)
case AI_ALL:
#if 1
/* illegal */
ERR(EAI_BADFLAGS);
SETERROR(EAI_BADFLAGS);
#else
pai->ai_flags &= ~(AI_ALL | AI_V4MAPPED);
break;
@ -407,7 +438,7 @@ getaddrinfo(hostname, servname, hints, res)
}
error = get_portmatch(pai, servname);
if (error)
ERR(error);
SETERROR(error);
*pai = ai0;
}
@ -466,9 +497,9 @@ getaddrinfo(hostname, servname, hints, res)
goto good;
if (pai->ai_flags & AI_NUMERICHOST)
ERR(EAI_NONAME);
SETERROR(EAI_NONAME);
if (hostname == NULL)
ERR(EAI_NONAME);
SETERROR(EAI_NONAME);
/*
* hostname as alphabetical name.
@ -490,7 +521,7 @@ getaddrinfo(hostname, servname, hints, res)
goto free;
}
if (afai == NULL) {
error = EAI_NONAME; /* we've had no errors. */
error = EAI_NONAME; /*%< we've had no errors. */
goto free;
}
@ -547,11 +578,7 @@ getaddrinfo(hostname, servname, hints, res)
cur = cur->ai_next;
}
freeaddrinfo(afai); /* afai must not be NULL at this point. */
/* we must not have got any errors. */
if (error != 0) /* just for diagnosis */
abort();
freeaddrinfo(afai); /*%< afai must not be NULL at this point. */
if (sentinel.ai_next) {
good:
@ -574,7 +601,7 @@ bad:
return(error);
}
/*
/*%
* FQDN hostname, DNS lookup
*/
static int
@ -602,7 +629,7 @@ explore_fqdn(pai, hostname, servname, res)
if (!net_data || !(ho = net_data->ho))
return(0);
#if 0 /* XXX (notyet) */
#if 0 /*%< XXX (notyet) */
if (net_data->ho_stayopen && net_data->ho_last &&
net_data->ho_last->h_addrtype == af) {
if (ns_samename(name, net_data->ho_last->h_name) == 1)
@ -638,7 +665,7 @@ explore_fqdn(pai, hostname, servname, res)
error = EAI_NONAME;
break;
default:
case NETDB_SUCCESS: /* should be impossible... */
case NETDB_SUCCESS: /*%< should be impossible... */
error = EAI_NONAME;
break;
}
@ -646,7 +673,7 @@ explore_fqdn(pai, hostname, servname, res)
}
for (cur = result; cur; cur = cur->ai_next) {
GET_PORT(cur, servname); /* XXX: redundant lookups... */
GET_PORT(cur, servname); /*%< XXX: redundant lookups... */
/* canonname should already be filled. */
}
@ -662,8 +689,8 @@ free:
static int
explore_copy(pai, src0, res)
const struct addrinfo *pai; /* seed */
const struct addrinfo *src0; /* source */
const struct addrinfo *pai; /*%< seed */
const struct addrinfo *src0; /*%< source */
struct addrinfo **res;
{
int error;
@ -697,7 +724,7 @@ fail:
return error;
}
/*
/*%
* hostname == NULL.
* passive socket -> anyaddr (0.0.0.0 or ::)
* non-passive socket -> localhost (127.0.0.1 or ::1)
@ -745,7 +772,7 @@ free:
return error;
}
/*
/*%
* numeric hostname
*/
static int
@ -777,10 +804,10 @@ explore_numeric(pai, hostname, servname, res)
pai->ai_family == PF_UNSPEC /*?*/) {
GET_AI(cur->ai_next, afd, pton);
GET_PORT(cur->ai_next, servname);
while (cur && cur->ai_next)
while (cur->ai_next)
cur = cur->ai_next;
} else
ERR(EAI_FAMILY); /*xxx*/
SETERROR(EAI_FAMILY); /*xxx*/
}
break;
#endif
@ -790,10 +817,10 @@ explore_numeric(pai, hostname, servname, res)
pai->ai_family == PF_UNSPEC /*?*/) {
GET_AI(cur->ai_next, afd, pton);
GET_PORT(cur->ai_next, servname);
while (cur && cur->ai_next)
while (cur->ai_next)
cur = cur->ai_next;
} else
ERR(EAI_FAMILY); /*xxx*/
SETERROR(EAI_FAMILY); /*xxx*/
}
break;
}
@ -808,7 +835,7 @@ bad:
return error;
}
/*
/*%
* numeric hostname with scope
*/
static int
@ -859,7 +886,7 @@ explore_numeric_scope(pai, hostname, servname, res)
sin6 = (struct sockaddr_in6 *)(void *)cur->ai_addr;
if (!ip6_str2scopeid(scope, sin6, &scopeid)) {
free(hostname2);
return(EAI_NONAME); /* XXX: is return OK? */
return(EAI_NONAME); /*%< XXX: is return OK? */
}
#ifdef HAVE_SIN6_SCOPE_ID
sin6->sin6_scope_id = scopeid;
@ -1055,7 +1082,7 @@ find_afd(af)
return NULL;
}
/*
/*%
* post-2553: AI_ADDRCONFIG check. if we use getipnodeby* as backend, backend
* will take care of it.
* the semantics of AI_ADDRCONFIG is not defined well. we are not sure
@ -1113,8 +1140,7 @@ ip6_str2scopeid(char *scope, struct sockaddr_in6 *sin6,
if (IN6_IS_ADDR_MC_ORGLOCAL(a6))
goto trynumeric;
else
goto trynumeric; /* global */
goto trynumeric; /*%< global */
/* try to convert to a numeric id as a last resort */
trynumeric:
errno = 0;
@ -1151,7 +1177,7 @@ hostent2addrinfo(hp, pai)
cur = &sentinel;
for (i = 0; (ap = aplist[i]) != NULL; i++) {
#if 0 /* the trick seems too much */
#if 0 /*%< the trick seems too much */
af = hp->h_addr_list;
if (af == AF_INET6 &&
IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) {
@ -1175,7 +1201,7 @@ hostent2addrinfo(hp, pai)
*/
GET_CANONNAME(cur->ai_next, hp->h_name);
}
while (cur && cur->ai_next) /* no need to loop, actually. */
while (cur->ai_next) /*%< no need to loop, actually. */
cur = cur->ai_next;
continue;

View File

@ -0,0 +1,224 @@
/*
* 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.
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: getgrent.c,v 1.5 2005/04/27 04:56:24 sra Exp $";
#endif
/* Imports */
#include "port_before.h"
#if !defined(WANT_IRS_GR) || defined(__BIND_NOSTATIC)
static int __bind_irs_gr_unneeded;
#else
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <errno.h>
#include <grp.h>
#include <resolv.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <irs.h>
#include "port_after.h"
#include "irs_data.h"
/* Forward */
static struct net_data *init(void);
void endgrent(void);
/* Public */
struct group *
getgrent() {
struct net_data *net_data = init();
return (getgrent_p(net_data));
}
struct group *
getgrnam(const char *name) {
struct net_data *net_data = init();
return (getgrnam_p(name, net_data));
}
struct group *
getgrgid(gid_t gid) {
struct net_data *net_data = init();
return (getgrgid_p(gid, net_data));
}
int
setgroupent(int stayopen) {
struct net_data *net_data = init();
return (setgroupent_p(stayopen, net_data));
}
#ifdef SETGRENT_VOID
void
setgrent(void) {
struct net_data *net_data = init();
setgrent_p(net_data);
}
#else
int
setgrent(void) {
struct net_data *net_data = init();
return (setgrent_p(net_data));
}
#endif /* SETGRENT_VOID */
void
endgrent() {
struct net_data *net_data = init();
endgrent_p(net_data);
}
int
getgrouplist(GETGROUPLIST_ARGS) {
struct net_data *net_data = init();
return (getgrouplist_p(name, basegid, groups, ngroups, net_data));
}
/* Shared private. */
struct group *
getgrent_p(struct net_data *net_data) {
struct irs_gr *gr;
if (!net_data || !(gr = net_data->gr))
return (NULL);
net_data->gr_last = (*gr->next)(gr);
return (net_data->gr_last);
}
struct group *
getgrnam_p(const char *name, struct net_data *net_data) {
struct irs_gr *gr;
if (!net_data || !(gr = net_data->gr))
return (NULL);
if (net_data->gr_stayopen && net_data->gr_last &&
!strcmp(net_data->gr_last->gr_name, name))
return (net_data->gr_last);
net_data->gr_last = (*gr->byname)(gr, name);
if (!net_data->gr_stayopen)
endgrent();
return (net_data->gr_last);
}
struct group *
getgrgid_p(gid_t gid, struct net_data *net_data) {
struct irs_gr *gr;
if (!net_data || !(gr = net_data->gr))
return (NULL);
if (net_data->gr_stayopen && net_data->gr_last &&
(gid_t)net_data->gr_last->gr_gid == gid)
return (net_data->gr_last);
net_data->gr_last = (*gr->bygid)(gr, gid);
if (!net_data->gr_stayopen)
endgrent();
return (net_data->gr_last);
}
int
setgroupent_p(int stayopen, struct net_data *net_data) {
struct irs_gr *gr;
if (!net_data || !(gr = net_data->gr))
return (0);
(*gr->rewind)(gr);
net_data->gr_stayopen = (stayopen != 0);
if (stayopen == 0)
net_data_minimize(net_data);
return (1);
}
#ifdef SETGRENT_VOID
void
setgrent_p(struct net_data *net_data) {
(void)setgroupent_p(0, net_data);
}
#else
int
setgrent_p(struct net_data *net_data) {
return (setgroupent_p(0, net_data));
}
#endif /* SETGRENT_VOID */
void
endgrent_p(struct net_data *net_data) {
struct irs_gr *gr;
if ((net_data != NULL) && ((gr = net_data->gr) != NULL))
(*gr->minimize)(gr);
}
int
getgrouplist_p(const char *name, gid_t basegid, gid_t *groups, int *ngroups,
struct net_data *net_data) {
struct irs_gr *gr;
if (!net_data || !(gr = net_data->gr)) {
*ngroups = 0;
return (-1);
}
return ((*gr->list)(gr, name, basegid, groups, ngroups));
}
/* Private */
static struct net_data *
init() {
struct net_data *net_data;
if (!(net_data = net_data_init(NULL)))
goto error;
if (!net_data->gr) {
net_data->gr = (*net_data->irs->gr_map)(net_data->irs);
if (!net_data->gr || !net_data->res) {
error:
errno = EIO;
return (NULL);
}
(*net_data->gr->res_set)(net_data->gr, net_data->res,
NULL);
}
return (net_data);
}
#endif /* WANT_IRS_GR */
/*! \file */

View File

@ -0,0 +1,230 @@
/*
* 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: getgrent_r.c,v 1.7 2005/04/27 04:56:24 sra Exp $";
#endif /* LIBC_SCCS and not lint */
#include <port_before.h>
#if !defined(_REENTRANT) || !defined(DO_PTHREADS) || !defined(WANT_IRS_PW)
static int getgrent_r_not_required = 0;
#else
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#if (defined(POSIX_GETGRNAM_R) || defined(POSIX_GETGRGID_R)) && \
defined(_POSIX_PTHREAD_SEMANTICS)
/* turn off solaris remapping in <grp.h> */
#define _UNIX95
#undef _POSIX_PTHREAD_SEMANTICS
#include <grp.h>
#define _POSIX_PTHREAD_SEMANTICS 1
#else
#include <grp.h>
#endif
#include <sys/param.h>
#include <port_after.h>
#ifdef GROUP_R_RETURN
static int
copy_group(struct group *, struct group *, char *buf, int buflen);
/* POSIX 1003.1c */
#ifdef POSIX_GETGRNAM_R
int
__posix_getgrnam_r(const char *name, struct group *gptr,
char *buf, int buflen, struct group **result) {
#else
int
getgrnam_r(const char *name, struct group *gptr,
char *buf, size_t buflen, struct group **result) {
#endif
struct group *ge = getgrnam(name);
int res;
if (ge == NULL) {
*result = NULL;
return (0);
}
res = copy_group(ge, gptr, buf, buflen);
*result = res ? NULL : gptr;
return (res);
}
#ifdef POSIX_GETGRNAM_R
struct group *
getgrnam_r(const char *name, struct group *gptr,
char *buf, int buflen) {
struct group *ge = getgrnam(name);
int res;
if (ge == NULL)
return (NULL);
res = copy_group(ge, gptr, buf, buflen);
return (res ? NULL : gptr);
}
#endif /* POSIX_GETGRNAM_R */
/* POSIX 1003.1c */
#ifdef POSIX_GETGRGID_R
int
__posix_getgrgid_r(gid_t gid, struct group *gptr,
char *buf, int buflen, struct group **result) {
#else /* POSIX_GETGRGID_R */
int
getgrgid_r(gid_t gid, struct group *gptr,
char *buf, size_t buflen, struct group **result) {
#endif /* POSIX_GETGRGID_R */
struct group *ge = getgrgid(gid);
int res;
if (ge == NULL) {
*result = NULL;
return (0);
}
res = copy_group(ge, gptr, buf, buflen);
*result = res ? NULL : gptr;
return (res);
}
#ifdef POSIX_GETGRGID_R
struct group *
getgrgid_r(gid_t gid, struct group *gptr,
char *buf, int buflen) {
struct group *ge = getgrgid(gid);
int res;
if (ge == NULL)
return (NULL);
res = copy_group(ge, gptr, buf, buflen);
return (res ? NULL : gptr);
}
#endif
/*%
* These assume a single context is in operation per thread.
* If this is not the case we will need to call irs directly
* rather than through the base functions.
*/
GROUP_R_RETURN
getgrent_r(struct group *gptr, GROUP_R_ARGS) {
struct group *ge = getgrent();
int res;
if (ge == NULL) {
return (GROUP_R_BAD);
}
res = copy_group(ge, gptr, buf, buflen);
return (res ? GROUP_R_BAD : GROUP_R_OK);
}
GROUP_R_SET_RETURN
setgrent_r(GROUP_R_ENT_ARGS) {
setgrent();
#ifdef GROUP_R_SET_RESULT
return (GROUP_R_SET_RESULT);
#endif
}
GROUP_R_END_RETURN
endgrent_r(GROUP_R_ENT_ARGS) {
endgrent();
GROUP_R_END_RESULT(GROUP_R_OK);
}
#if 0
/* XXX irs does not have a fgetgrent() */
GROUP_R_RETURN
fgetgrent_r(FILE *f, struct group *gptr, GROUP_R_ARGS) {
struct group *ge = fgetgrent(f);
int res;
if (ge == NULL)
return (GROUP_R_BAD);
res = copy_group(ge, gptr, buf, buflen);
return (res ? GROUP_R_BAD : GROUP_R_OK);
}
#endif
/* Private */
static int
copy_group(struct group *ge, struct group *gptr, char *buf, int buflen) {
char *cp;
int i, n;
int numptr, len;
/* Find out the amount of space required to store the answer. */
numptr = 1; /*%< NULL ptr */
len = (char *)ALIGN(buf) - buf;
for (i = 0; ge->gr_mem[i]; i++, numptr++) {
len += strlen(ge->gr_mem[i]) + 1;
}
len += strlen(ge->gr_name) + 1;
len += strlen(ge->gr_passwd) + 1;
len += numptr * sizeof(char*);
if (len > buflen) {
errno = ERANGE;
return (ERANGE);
}
/* copy group id */
gptr->gr_gid = ge->gr_gid;
cp = (char *)ALIGN(buf) + numptr * sizeof(char *);
/* copy official name */
n = strlen(ge->gr_name) + 1;
strcpy(cp, ge->gr_name);
gptr->gr_name = cp;
cp += n;
/* copy member list */
gptr->gr_mem = (char **)ALIGN(buf);
for (i = 0 ; ge->gr_mem[i]; i++) {
n = strlen(ge->gr_mem[i]) + 1;
strcpy(cp, ge->gr_mem[i]);
gptr->gr_mem[i] = cp;
cp += n;
}
gptr->gr_mem[i] = NULL;
/* copy password */
n = strlen(ge->gr_passwd) + 1;
strcpy(cp, ge->gr_passwd);
gptr->gr_passwd = cp;
cp += n;
return (0);
}
#else /* GROUP_R_RETURN */
static int getgrent_r_unknown_system = 0;
#endif /* GROUP_R_RETURN */
#endif /* !def(_REENTRANT) || !def(DO_PTHREADS) || !def(WANT_IRS_PW) */
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: gethostent.c 18075 2006-07-08 14:40:33Z axeld $";
static const char rcsid[] = "$Id: gethostent.c,v 1.8 2006/01/10 05:06:00 marka Exp $";
#endif
/* Imports */
@ -235,11 +235,11 @@ static const unsigned char in6addr_mapped[12] = {
static int scan_interfaces(int *, int *);
static struct hostent *copyandmerge(struct hostent *, struct hostent *, int, int *);
/*
/*%
* Public functions
*/
/*
/*%
* AI_V4MAPPED + AF_INET6
* If no IPv6 address then a query for IPv4 and map returned values.
*
@ -445,11 +445,11 @@ freehostent(struct hostent *he) {
memput(he, sizeof *he);
}
/*
/*%
* Private
*/
/*
/*%
* Scan the interface table and set have_v4 and have_v6 depending
* upon whether there are IPv4 and IPv6 interface addresses.
*
@ -505,7 +505,7 @@ scan_interfaces6(int *have_v4, int *have_v6) {
if (buf == NULL)
goto cleanup;
#ifdef SETFAMILYFLAGS
lifc.lifc_family = AF_UNSPEC; /* request all families */
lifc.lifc_family = AF_UNSPEC; /*%< request all families */
lifc.lifc_flags = 0;
#endif
lifc.lifc_len = bufsiz;
@ -533,7 +533,7 @@ scan_interfaces6(int *have_v4, int *have_v6) {
}
/* Parse system's interface list. */
cplim = buf + lifc.lifc_len; /* skip over if's with big ifr_addr's */
cplim = buf + lifc.lifc_len; /*%< skip over if's with big ifr_addr's */
for (cp = buf;
(*have_v4 == 0 || *have_v6 == 0) && cp < cplim;
cp += cpsize) {
@ -608,7 +608,7 @@ scan_interfaces6(int *have_v4, int *have_v6) {
}
#endif
#ifdef __linux
#if ( defined(__linux__) || defined(__linux) || defined(LINUX) )
#ifndef IF_NAMESIZE
# ifdef IFNAMSIZ
# define IF_NAMESIZE IFNAMSIZ
@ -639,7 +639,7 @@ static int
scan_interfaces(int *have_v4, int *have_v6) {
struct ifconf ifc;
union {
char _pad[256]; /* leave space for IPv6 addresses */
char _pad[256]; /*%< leave space for IPv6 addresses */
struct ifreq ifreq;
} u;
struct in_addr in4;
@ -712,7 +712,7 @@ scan_interfaces(int *have_v4, int *have_v6) {
}
/* Parse system's interface list. */
cplim = buf + ifc.ifc_len; /* skip over if's with big ifr_addr's */
cplim = buf + ifc.ifc_len; /*%< skip over if's with big ifr_addr's */
for (cp = buf;
(*have_v4 == 0 || *have_v6 == 0) && cp < cplim;
cp += cpsize) {
@ -792,8 +792,8 @@ scan_interfaces(int *have_v4, int *have_v6) {
static struct hostent *
copyandmerge(struct hostent *he1, struct hostent *he2, int af, int *error_num) {
struct hostent *he = NULL;
int addresses = 1; /* NULL terminator */
int names = 1; /* NULL terminator */
int addresses = 1; /*%< NULL terminator */
int names = 1; /*%< NULL terminator */
int len = 0;
char **cpp, **npp;
@ -1034,7 +1034,7 @@ fakeaddr(const char *name, int af, struct net_data *net_data) {
return (&pvt->host);
}
#ifdef grot /* for future use in gethostbyaddr(), for "SUNSECURITY" */
#ifdef grot /*%< for future use in gethostbyaddr(), for "SUNSECURITY" */
struct hostent *rhp;
char **haddr;
u_long old_options;
@ -1065,5 +1065,6 @@ fakeaddr(const char *name, int af, struct net_data *net_data) {
}
}
#endif /* grot */
#endif /*__BIND_NOSTATIC*/
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: gethostent_r.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: gethostent_r.c,v 1.9 2005/09/03 12:41:37 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <port_before.h>
@ -34,7 +34,7 @@ static const char rcsid[] = "$Id: gethostent_r.c 15570 2005-12-16 22:38:13Z wkor
#ifdef HOST_R_RETURN
static HOST_R_RETURN
static HOST_R_RETURN
copy_hostent(struct hostent *, struct hostent *, HOST_R_COPY_ARGS);
HOST_R_RETURN
@ -44,14 +44,16 @@ gethostbyname_r(const char *name, struct hostent *hptr, HOST_R_ARGS) {
int n = 0;
#endif
#ifdef HOST_R_ERRNO
HOST_R_ERRNO;
#endif
#ifdef HOST_R_SETANSWER
if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) != 0)
*answerp = NULL;
else
*answerp = hptr;
return (n);
#else
if (he == NULL)
@ -69,14 +71,16 @@ gethostbyaddr_r(const char *addr, int len, int type,
int n = 0;
#endif
#ifdef HOST_R_ERRNO
HOST_R_ERRNO;
#endif
#ifdef HOST_R_SETANSWER
if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) != 0)
*answerp = NULL;
else
*answerp = hptr;
return (n);
#else
if (he == NULL)
@ -86,7 +90,7 @@ gethostbyaddr_r(const char *addr, int len, int type,
#endif
}
/*
/*%
* These assume a single context is in operation per thread.
* If this is not the case we will need to call irs directly
* rather than through the base functions.
@ -99,14 +103,16 @@ gethostent_r(struct hostent *hptr, HOST_R_ARGS) {
int n = 0;
#endif
#ifdef HOST_R_ERRNO
HOST_R_ERRNO;
#endif
#ifdef HOST_R_SETANSWER
if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) != 0)
*answerp = NULL;
else
*answerp = hptr;
return (n);
#else
if (he == NULL)
@ -123,6 +129,9 @@ sethostent_r(int stay_open, HOST_R_ENT_ARGS)
sethostent_r(int stay_open)
#endif
{
#ifdef HOST_R_ENT_ARGS
UNUSED(hdptr);
#endif
sethostent(stay_open);
#ifdef HOST_R_SET_RESULT
return (HOST_R_SET_RESULT);
@ -136,6 +145,9 @@ endhostent_r(HOST_R_ENT_ARGS)
endhostent_r(void)
#endif
{
#ifdef HOST_R_ENT_ARGS
UNUSED(hdptr);
#endif
endhostent();
HOST_R_END_RESULT(HOST_R_OK);
}
@ -151,7 +163,7 @@ copy_hostent(struct hostent *he, struct hostent *hptr, HOST_R_COPY_ARGS) {
int nptr, len;
/* Find out the amount of space required to store the answer. */
nptr = 2; /* NULL ptrs */
nptr = 2; /*%< NULL ptrs */
len = (char *)ALIGN(buf) - buf;
for (i = 0; he->h_addr_list[i]; i++, nptr++) {
len += he->h_length;
@ -161,7 +173,7 @@ copy_hostent(struct hostent *he, struct hostent *hptr, HOST_R_COPY_ARGS) {
}
len += strlen(he->h_name) + 1;
len += nptr * sizeof(char*);
if (len > buflen) {
errno = ERANGE;
return (HOST_R_BAD);
@ -260,3 +272,4 @@ copy_hostent(struct hostent *he, struct hostent *hptr, HOST_R_COPY_ARGS) {
static int gethostent_r_unknown_system = 0;
#endif /* HOST_R_RETURN */
#endif /* !defined(_REENTRANT) || !defined(DO_PTHREADS) */
/*! \file */

View File

@ -3,6 +3,16 @@
* - Thread safe-ness must be checked
*/
#if ( defined(__linux__) || defined(__linux) || defined(LINUX) )
#ifndef IF_NAMESIZE
# ifdef IFNAMSIZ
# define IF_NAMESIZE IFNAMSIZ
# else
# define IF_NAMESIZE 16
# endif
#endif
#endif
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
@ -53,7 +63,7 @@
#include <port_after.h>
/*
/*%
* Note that a_off will be dynamically adjusted so that to be consistent
* with the definition of sockaddr_in{,6}.
* The value presented below is just a guess.
@ -89,11 +99,11 @@ static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t, int));
int
getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
const struct sockaddr *sa;
socklen_t salen;
size_t salen;
char *host;
socklen_t hostlen;
size_t hostlen;
char *serv;
socklen_t servlen;
size_t servlen;
int flags;
{
struct afd *afd;
@ -129,7 +139,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
found:
if (salen != afd->a_socklen) return EAI_FAIL;
port = ((const struct sockinet *)sa)->si_port; /* network byte order */
port = ((const struct sockinet *)sa)->si_port; /*%< network byte order */
addr = (const char *)sa + afd->a_off;
if (serv == NULL || servlen == 0U) {
@ -241,13 +251,13 @@ ip6_parsenumeric(const struct sockaddr *sa, const char *addr, char *host,
return EAI_SYSTEM;
numaddrlen = strlen(numaddr);
if (numaddrlen + 1 > hostlen) /* don't forget terminator */
if (numaddrlen + 1 > hostlen) /*%< don't forget terminator */
return EAI_MEMORY;
strcpy(host, numaddr);
#ifdef HAVE_SIN6_SCOPE_ID
if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) {
char scopebuf[MAXHOSTNAMELEN]; /* XXX */
char scopebuf[MAXHOSTNAMELEN]; /*%< XXX */
int scopelen;
/* ip6_sa2str never fails */
@ -282,7 +292,7 @@ ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf,
#ifdef NI_NUMERICSCOPE
if (flags & NI_NUMERICSCOPE) {
sprintf(tmp, "%lu", sa6->sin6_scope_id);
sprintf(tmp, "%u", sa6->sin6_scope_id);
if (bufsiz != 0U) {
strncpy(buf, tmp, bufsiz - 1);
buf[bufsiz - 1] = '\0';
@ -312,7 +322,7 @@ ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf,
#endif
/* last resort */
sprintf(tmp, "%lu", sa6->sin6_scope_id);
sprintf(tmp, "%u", sa6->sin6_scope_id);
if (bufsiz != 0U) {
strncpy(buf, tmp, bufsiz - 1);
buf[bufsiz - 1] = '\0';
@ -320,3 +330,5 @@ ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf,
return(strlen(tmp));
}
#endif
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: getnetent.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: getnetent.c,v 1.7 2005/04/27 04:56:25 sra Exp $";
#endif
/* Imports */
@ -321,7 +321,7 @@ nw_to_net(struct nwent *nwent, struct net_data *net_data) {
pvt->netent.n_aliases = nwent->n_aliases;
pvt->netent.n_addrtype = nwent->n_addrtype;
/*
/*%
* What this code does: Converts net addresses from network to host form.
*
* msbyte: the index of the most significant byte in the n_addr array.
@ -341,3 +341,5 @@ nw_to_net(struct nwent *nwent, struct net_data *net_data) {
}
#endif /*__BIND_NOSTATIC*/
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: getnetent_r.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: getnetent_r.c,v 1.6 2005/09/03 12:41:38 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <port_before.h>
@ -83,7 +83,7 @@ getnetbyaddr_r(GETNETBYADDR_ADDR_T addr, int type, struct netent *nptr, NET_R_AR
#endif
}
/*
/*%
* These assume a single context is in operation per thread.
* If this is not the case we will need to call irs directly
* rather than through the base functions.
@ -118,6 +118,9 @@ setnetent_r(int stay_open, NET_R_ENT_ARGS)
setnetent_r(int stay_open)
#endif
{
#ifdef NET_R_ENT_ARGS
UNUSED(ndptr);
#endif
setnetent(stay_open);
#ifdef NET_R_SET_RESULT
return (NET_R_SET_RESULT);
@ -131,6 +134,9 @@ endnetent_r(NET_R_ENT_ARGS)
endnetent_r()
#endif
{
#ifdef NET_R_ENT_ARGS
UNUSED(ndptr);
#endif
endnetent();
NET_R_END_RESULT(NET_R_OK);
}
@ -145,7 +151,7 @@ copy_netent(struct netent *ne, struct netent *nptr, NET_R_COPY_ARGS) {
int numptr, len;
/* Find out the amount of space required to store the answer. */
numptr = 1; /* NULL ptr */
numptr = 1; /*%< NULL ptr */
len = (char *)ALIGN(buf) - buf;
for (i = 0; ne->n_aliases[i]; i++, numptr++) {
len += strlen(ne->n_aliases[i]) + 1;
@ -225,3 +231,4 @@ copy_netent(struct netent *ne, struct netent *nptr, NET_R_COPY_ARGS) {
static int getnetent_r_unknown_system = 0;
#endif /* NET_R_RETURN */
#endif /* !defined(_REENTRANT) || !defined(DO_PTHREADS) */
/*! \file */

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-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: getnetgrent.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: getnetgrent.c,v 1.6 2008/11/14 02:36:51 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/* Imports */
@ -76,7 +76,9 @@ innetgr(INNETGR_ARGS) {
}
int
getnetgrent(char **host, char **user, char **domain) {
getnetgrent(NGR_R_CONST char **host, NGR_R_CONST char **user,
NGR_R_CONST char **domain)
{
struct net_data *net_data = init();
const char *ch, *cu, *cd;
int ret;
@ -149,8 +151,10 @@ init(void) {
return (NULL);
}
}
return (net_data);
}
#endif /*__BIND_NOSTATIC*/
/*! \file */

View File

@ -1,22 +1,22 @@
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1998-1999 by Internet Software Consortium.
* Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 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: getnetgrent_r.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: getnetgrent_r.c,v 1.14 2008/11/14 02:36:51 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <port_before.h>
@ -33,10 +33,13 @@ static const char rcsid[] = "$Id: getnetgrent_r.c 15570 2005-12-16 22:38:13Z wko
#include <port_after.h>
#ifdef NGR_R_RETURN
#ifndef NGR_R_PRIVATE
#define NGR_R_PRIVATE 0
#endif
static NGR_R_RETURN
copy_protoent(char **, char **, char **, const char *, const char *,
const char *, NGR_R_COPY_ARGS);
static NGR_R_RETURN
copy_protoent(NGR_R_CONST char **, NGR_R_CONST char **, NGR_R_CONST char **,
const char *, const char *, const char *, NGR_R_COPY_ARGS);
NGR_R_RETURN
innetgr_r(const char *netgroup, const char *host, const char *user,
@ -51,36 +54,62 @@ innetgr_r(const char *netgroup, const char *host, const char *user,
return (innetgr(ng, ho, us, dom));
}
/*
/*%
* These assume a single context is in operation per thread.
* If this is not the case we will need to call irs directly
* rather than through the base functions.
*/
NGR_R_RETURN
getnetgrent_r(char **machinep, char **userp, char **domainp, NGR_R_ARGS) {
char *mp, *up, *dp;
getnetgrent_r(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
NGR_R_CONST char **domainp, NGR_R_ARGS)
{
NGR_R_CONST char *mp, *up, *dp;
int res = getnetgrent(&mp, &up, &dp);
if (res != 1)
if (res != 1)
return (res);
return (copy_protoent(machinep, userp, domainp,
mp, up, dp, NGR_R_COPY));
}
#if NGR_R_PRIVATE == 2
struct private {
char *buf;
};
#endif
NGR_R_SET_RETURN
#ifdef NGR_R_ENT_ARGS
setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS)
#ifdef NGR_R_SET_ARGS
setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS)
#else
setnetgrent_r(const char *netgroup)
setnetgrent_r(NGR_R_SET_CONST char *netgroup)
#endif
{
#if NGR_R_PRIVATE == 2
struct private *p;
#endif
char *tmp;
#if defined(NGR_R_SET_ARGS) && NGR_R_PRIVATE == 0
UNUSED(buf);
UNUSED(buflen);
#endif
DE_CONST(netgroup, tmp);
setnetgrent(tmp);
#ifdef NGR_R_PRIVATE
#if NGR_R_PRIVATE == 1
*buf = NULL;
#elif NGR_R_PRIVATE == 2
*buf = p = malloc(sizeof(struct private));
if (p == NULL)
#ifdef NGR_R_SET_RESULT
return (NGR_R_BAD);
#else
return;
#endif
p->buf = NULL;
#endif
#ifdef NGR_R_SET_RESULT
return (NGR_R_SET_RESULT);
@ -88,17 +117,29 @@ setnetgrent_r(const char *netgroup)
}
NGR_R_END_RETURN
#ifdef NGR_R_ENT_ARGS
endnetgrent_r(NGR_R_ENT_ARGS)
#ifdef NGR_R_END_ARGS
endnetgrent_r(NGR_R_END_ARGS)
#else
endnetgrent_r(void)
#endif
{
#if NGR_R_PRIVATE == 2
struct private *p = buf;
#endif
#if defined(NGR_R_SET_ARGS) && NGR_R_PRIVATE == 0
UNUSED(buf);
UNUSED(buflen);
#endif
endnetgrent();
#ifdef NGR_R_PRIVATE
#if NGR_R_PRIVATE == 1
if (*buf != NULL)
free(*buf);
*buf = NULL;
#elif NGR_R_PRIVATE == 2
if (p->buf != NULL)
free(p->buf);
free(p);
#endif
NGR_R_END_RESULT(NGR_R_OK);
}
@ -106,9 +147,13 @@ endnetgrent_r(void)
/* Private */
static int
copy_protoent(char **machinep, char **userp, char **domainp,
const char *mp, const char *up, const char *dp,
NGR_R_COPY_ARGS) {
copy_protoent(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
NGR_R_CONST char **domainp, const char *mp, const char *up,
const char *dp, NGR_R_COPY_ARGS)
{
#if NGR_R_PRIVATE == 2
struct private *p = buf;
#endif
char *cp;
int n;
int len;
@ -118,13 +163,21 @@ copy_protoent(char **machinep, char **userp, char **domainp,
if (mp != NULL) len += strlen(mp) + 1;
if (up != NULL) len += strlen(up) + 1;
if (dp != NULL) len += strlen(dp) + 1;
#ifdef NGR_R_PRIVATE
free(*buf);
#if NGR_R_PRIVATE == 1
if (*buf != NULL)
free(*buf);
*buf = malloc(len);
if (*buf == NULL)
return(NGR_R_BAD);
cp = *buf;
#elif NGR_R_PRIVATE == 2
if (p->buf)
free(p->buf);
p->buf = malloc(len);
if (p->buf == NULL)
return(NGR_R_BAD);
cp = p->buf;
#else
if (len > (int)buflen) {
errno = ERANGE;
@ -133,7 +186,6 @@ copy_protoent(char **machinep, char **userp, char **domainp,
cp = buf;
#endif
if (mp != NULL) {
n = strlen(mp) + 1;
strcpy(cp, mp);
@ -164,3 +216,4 @@ copy_protoent(char **machinep, char **userp, char **domainp,
static int getnetgrent_r_unknown_system = 0;
#endif /* NGR_R_RETURN */
#endif /* !defined(_REENTRANT) || !defined(DO_PTHREADS) */
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if !defined(LINT) && !defined(CODECENTER)
static const char rcsid[] = "$Id: getprotoent.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: getprotoent.c,v 1.4 2005/04/27 04:56:26 sra Exp $";
#endif
/* Imports */
@ -172,3 +172,5 @@ init() {
}
#endif /*__BIND_NOSTATIC*/
/*! \file */

View File

@ -16,7 +16,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: getprotoent_r.c 15570 2005-12-16 22:38:13Z wkornew $";
static const char rcsid[] = "$Id: getprotoent_r.c,v 1.6 2006/08/01 01:14:16 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <port_before.h>
@ -76,7 +76,7 @@ getprotobynumber_r(int proto, struct protoent *pptr, PROTO_R_ARGS) {
#endif
}
/*
/*%
* These assume a single context is in operation per thread.
* If this is not the case we will need to call irs directly
* rather than through the base functions.
@ -109,6 +109,9 @@ setprotoent_r(int stay_open, PROTO_R_ENT_ARGS)
setprotoent_r(int stay_open)
#endif
{
#ifdef PROTO_R_ENT_UNUSED
PROTO_R_ENT_UNUSED;
#endif
setprotoent(stay_open);
#ifdef PROTO_R_SET_RESULT
return (PROTO_R_SET_RESULT);
@ -122,6 +125,9 @@ endprotoent_r(PROTO_R_ENT_ARGS)
endprotoent_r()
#endif
{
#ifdef PROTO_R_ENT_UNUSED
PROTO_R_ENT_UNUSED;
#endif
endprotoent();
PROTO_R_END_RESULT(PROTO_R_OK);
}
@ -136,7 +142,7 @@ copy_protoent(struct protoent *pe, struct protoent *pptr, PROTO_R_COPY_ARGS) {
int numptr, len;
/* Find out the amount of space required to store the answer. */
numptr = 1; /* NULL ptr */
numptr = 1; /*%< NULL ptr */
len = (char *)ALIGN(buf) - buf;
for (i = 0; pe->p_aliases[i]; i++, numptr++) {
len += strlen(pe->p_aliases[i]) + 1;
@ -214,3 +220,4 @@ copy_protoent(struct protoent *pe, struct protoent *pptr, PROTO_R_COPY_ARGS) {
static int getprotoent_r_unknown_system = 0;
#endif /* PROTO_R_RETURN */
#endif /* !defined(_REENTRANT) || !defined(DO_PTHREADS) */
/*! \file */

Some files were not shown because too many files have changed in this diff Show More