Sync up nameser with upstream(2014.03.05)
Bug: 13219633
Change-Id: I8ee4ddf270710e9eea415fa3db984af7719a8dd4
diff --git a/libc/include/arpa/nameser.h b/libc/include/arpa/nameser.h
index c339db3..a87ac91 100644
--- a/libc/include/arpa/nameser.h
+++ b/libc/include/arpa/nameser.h
@@ -1,4 +1,21 @@
-/* $NetBSD: nameser.h,v 1.19 2005/12/26 19:01:47 perry Exp $ */
+/* $NetBSD: nameser.h,v 1.25 2009/04/12 17:07:34 christos Exp $ */
+
+/*
+ * 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
@@ -30,24 +47,7 @@
*/
/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1996-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
- * Id: nameser.h,v 1.2.2.4.4.1 2004/03/09 08:33:30 marka Exp
+ * Id: nameser.h,v 1.16 2009/03/03 01:52:48 each Exp
*/
#ifndef _ARPA_NAMESER_H_
@@ -66,16 +66,19 @@
* 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
+ * Define constants based on RFC0883, RFC1034, RFC 1035
*/
#define NS_PACKETSZ 512 /* default UDP packet size */
-#define NS_MAXDNAME 1025 /* maximum domain name */
+#define NS_MAXDNAME 1025 /* maximum domain name (presentation format)*/
#define NS_MAXMSG 65535 /* maximum message size */
#define NS_MAXCDNAME 255 /* maximum compressed domain name */
#define NS_MAXLABEL 63 /* maximum length of domain label */
+#define NS_MAXLABELS 128 /* theoretical max #/labels per domain name */
+#define NS_MAXNNAME 256 /* maximum uncompressed (binary) domain name*/
+#define NS_MAXPADDR (sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
#define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */
#define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */
#define NS_RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
@@ -103,6 +106,18 @@
} 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.
@@ -115,6 +130,16 @@
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; };
@@ -140,8 +165,22 @@
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) ((u_long)(rr).ttl + 0)
@@ -274,7 +313,7 @@
ns_t_key = 25, /* Security key. */
ns_t_px = 26, /* X.400 mail mapping. */
ns_t_gpos = 27, /* Geographical position (withdrawn). */
- ns_t_aaaa = 28, /* Ip6 Address. */
+ ns_t_aaaa = 28, /* IPv6 Address. */
ns_t_loc = 29, /* Location Information. */
ns_t_nxt = 30, /* Next domain (security). */
ns_t_eid = 31, /* Endpoint identifier. */
@@ -284,11 +323,22 @@
ns_t_naptr = 35, /* Naming Authority PoinTeR */
ns_t_kx = 36, /* Key Exchange */
ns_t_cert = 37, /* Certification record */
- ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */
- ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */
+ ns_t_a6 = 38, /* IPv6 address (experimental) */
+ ns_t_dname = 39, /* Non-terminal DNAME */
ns_t_sink = 40, /* Kitchen sink (experimentatl) */
ns_t_opt = 41, /* EDNS0 option (meta-RR) */
ns_t_apl = 42, /* Address prefix list (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. */
@@ -297,6 +347,7 @@
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;
@@ -423,9 +474,10 @@
#define NS_NXT_MAX 127
/*
- * EDNS0 extended flags, host order.
+ * 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.
@@ -477,6 +529,7 @@
#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
@@ -485,12 +538,19 @@
#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
@@ -504,6 +564,16 @@
#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(ns_msg, int);
@@ -514,6 +584,7 @@
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 *,
@@ -526,8 +597,12 @@
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 *,
@@ -542,6 +617,11 @@
int ns_sign2(u_char *, int *, int, int, void *,
const u_char *, int, u_char *, int *, time_t,
u_char **, 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_tcp(u_char *, int *, int, int,
ns_tcp_tsig_state *, int);
int ns_sign_tcp2(u_char *, int *, int, int,
@@ -560,17 +640,29 @@
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, uint16_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, uint32_t ttl,
+ uint16_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
-#if 0
-# include "private/libc_logging.h"
-# define XLOG(...) __libc_format_log(ANDROID_LOG_DEBUG,"libc",__VA_ARGS__)
-#else
-#define XLOG(...) do {} while (0)
-#endif
-
#endif /* !_ARPA_NAMESER_H_ */