add and use and bind9 version of rr type (rk_ns_t_XXX) instead of the

old bind4 version (T_XXX)


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13945 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2004-06-20 17:50:09 +00:00
parent a31166df82
commit e8acf0bd31
2 changed files with 96 additions and 40 deletions

View File

@@ -53,26 +53,26 @@ RCSID("$Id$");
#if (defined(HAVE_RES_SEARCH) || defined(HAVE_RES_NSEARCH)) && defined(HAVE_DN_EXPAND)
#define DECL(X) {#X, T_##X}
#define DECL(X) {#X, rk_ns_t_##X}
static struct stot{
const char *name;
int type;
}stot[] = {
DECL(A),
DECL(AAAA),
DECL(NS),
DECL(CNAME),
DECL(SOA),
DECL(PTR),
DECL(MX),
DECL(TXT),
DECL(AFSDB),
DECL(SIG),
DECL(KEY),
DECL(SRV),
DECL(NAPTR),
DECL(SSHFP),
DECL(a),
DECL(aaaa),
DECL(ns),
DECL(cname),
DECL(soa),
DECL(ptr),
DECL(mx),
DECL(txt),
DECL(afsdb),
DECL(sig),
DECL(key),
DECL(srv),
DECL(naptr),
DECL(sshfp),
{NULL, 0}
};
@@ -155,9 +155,9 @@ parse_record(const unsigned char *data, const unsigned char *end_data,
(*rr)->ttl = ttl;
(*rr)->size = size;
switch(type){
case T_NS:
case T_CNAME:
case T_PTR:
case rk_ns_t_ns:
case rk_ns_t_cname:
case rk_ns_t_ptr:
status = dn_expand(data, end_data, p, host, sizeof(host));
if(status < 0) {
free(*rr);
@@ -169,8 +169,8 @@ parse_record(const unsigned char *data, const unsigned char *end_data,
return -1;
}
break;
case T_MX:
case T_AFSDB:{
case rk_ns_t_mx:
case rk_ns_t_afsdb:{
size_t hostlen;
status = dn_expand(data, end_data, p + 2, host, sizeof(host));
@@ -194,7 +194,7 @@ parse_record(const unsigned char *data, const unsigned char *end_data,
strlcpy((*rr)->u.mx->domain, host, hostlen + 1);
break;
}
case T_SRV:{
case rk_ns_t_srv:{
size_t hostlen;
status = dn_expand(data, end_data, p + 6, host, sizeof(host));
if(status < 0){
@@ -220,7 +220,7 @@ parse_record(const unsigned char *data, const unsigned char *end_data,
strlcpy((*rr)->u.srv->target, host, hostlen + 1);
break;
}
case T_TXT:{
case rk_ns_t_txt:{
if(size == 0 || size < *p + 1) {
free(*rr);
return -1;
@@ -234,7 +234,7 @@ parse_record(const unsigned char *data, const unsigned char *end_data,
(*rr)->u.txt[*p] = '\0';
break;
}
case T_KEY : {
case rk_ns_t_key : {
size_t key_len;
if (size < 4) {
@@ -256,7 +256,7 @@ parse_record(const unsigned char *data, const unsigned char *end_data,
memcpy ((*rr)->u.key->key_data, p + 4, key_len);
break;
}
case T_SIG : {
case rk_ns_t_sig : {
size_t sig_len, hostlen;
if(size <= 18) {
@@ -303,7 +303,7 @@ parse_record(const unsigned char *data, const unsigned char *end_data,
break;
}
case T_CERT : {
case rk_ns_t_cert : {
size_t cert_len;
if (size < 5) {
@@ -325,7 +325,7 @@ parse_record(const unsigned char *data, const unsigned char *end_data,
memcpy ((*rr)->u.cert->cert_data, p + 5, cert_len);
break;
}
case T_SSHFP : {
case rk_ns_t_sshfp : {
size_t sshfp_len;
unsigned type;
@@ -552,7 +552,7 @@ dns_srv_order(struct dns_reply *r)
#endif
for(rr = r->head; rr; rr = rr->next)
if(rr->type == T_SRV)
if(rr->type == rk_ns_t_srv)
num_srv++;
if(num_srv == 0)
@@ -565,7 +565,7 @@ dns_srv_order(struct dns_reply *r)
/* unlink all srv-records from the linked list and put them in
a vector */
for(ss = srvs, headp = &r->head; *headp; )
if((*headp)->type == T_SRV) {
if((*headp)->type == rk_ns_t_srv) {
*ss = *headp;
*headp = (*headp)->next;
(*ss)->next = NULL;
@@ -659,36 +659,36 @@ main(int argc, char **argv)
printf("No reply.\n");
return 1;
}
if(r->q.type == T_SRV)
if(r->q.type == rk_ns_t_srv)
dns_srv_order(r);
for(rr = r->head; rr;rr=rr->next){
printf("%-30s %-5s %-6d ", rr->domain, dns_type_to_string(rr->type), rr->ttl);
switch(rr->type){
case T_NS:
case T_CNAME:
case T_PTR:
case rk_ns_t_ns:
case rk_ns_t_cname:
case rk_ns_t_ptr:
printf("%s\n", (char*)rr->u.data);
break;
case T_A:
case rk_ns_t_a:
printf("%s\n", inet_ntoa(*rr->u.a));
break;
case T_MX:
case T_AFSDB:{
case rk_ns_t_mx:
case rk_ns_t_afsdb:{
printf("%d %s\n", rr->u.mx->preference, rr->u.mx->domain);
break;
}
case T_SRV:{
case rk_ns_t_srv:{
struct srv_record *srv = rr->u.srv;
printf("%d %d %d %s\n", srv->priority, srv->weight,
srv->port, srv->target);
break;
}
case T_TXT: {
case rk_ns_t_txt: {
printf("%s\n", rr->u.txt);
break;
}
case T_SIG : {
case rk_ns_t_sig : {
struct sig_record *sig = rr->u.sig;
const char *type_string = dns_type_to_string (sig->type);
@@ -699,14 +699,14 @@ main(int argc, char **argv)
sig->signer);
break;
}
case T_KEY : {
case rk_ns_t_key : {
struct key_record *key = rr->u.key;
printf ("flags %u, protocol %u, algorithm %u\n",
key->flags, key->protocol, key->algorithm);
break;
}
case T_SSHFP : {
case rk_ns_t_sshfp : {
struct sshfp_record *sshfp = rr->u.sshfp;
int i;

View File

@@ -36,6 +36,62 @@
#ifndef __RESOLVE_H__
#define __RESOLVE_H__
typedef enum {
rk_ns_t_invalid = 0, /* Cookie. */
rk_ns_t_a = 1, /* Host address. */
rk_ns_t_ns = 2, /* Authoritative server. */
rk_ns_t_md = 3, /* Mail destination. */
rk_ns_t_mf = 4, /* Mail forwarder. */
rk_ns_t_cname = 5, /* Canonical name. */
rk_ns_t_soa = 6, /* Start of authority zone. */
rk_ns_t_mb = 7, /* Mailbox domain name. */
rk_ns_t_mg = 8, /* Mail group member. */
rk_ns_t_mr = 9, /* Mail rename name. */
rk_ns_t_null = 10, /* Null resource record. */
rk_ns_t_wks = 11, /* Well known service. */
rk_ns_t_ptr = 12, /* Domain name pointer. */
rk_ns_t_hinfo = 13, /* Host information. */
rk_ns_t_minfo = 14, /* Mailbox information. */
rk_ns_t_mx = 15, /* Mail routing information. */
rk_ns_t_txt = 16, /* Text strings. */
rk_ns_t_rp = 17, /* Responsible person. */
rk_ns_t_afsdb = 18, /* AFS cell database. */
rk_ns_t_x25 = 19, /* X_25 calling address. */
rk_ns_t_isdn = 20, /* ISDN calling address. */
rk_ns_t_rt = 21, /* Router. */
rk_ns_t_nsap = 22, /* NSAP address. */
rk_ns_t_nsap_ptr = 23, /* Reverse NSAP lookup (deprecated). */
rk_ns_t_sig = 24, /* Security signature. */
rk_ns_t_key = 25, /* Security key. */
rk_ns_t_px = 26, /* X.400 mail mapping. */
rk_ns_t_gpos = 27, /* Geographical position (withdrawn). */
rk_ns_t_aaaa = 28, /* Ip6 Address. */
rk_ns_t_loc = 29, /* Location Information. */
rk_ns_t_nxt = 30, /* Next domain (security). */
rk_ns_t_eid = 31, /* Endpoint identifier. */
rk_ns_t_nimloc = 32, /* Nimrod Locator. */
rk_ns_t_srv = 33, /* Server Selection. */
rk_ns_t_atma = 34, /* ATM Address */
rk_ns_t_naptr = 35, /* Naming Authority PoinTeR */
rk_ns_t_kx = 36, /* Key Exchange */
rk_ns_t_cert = 37, /* Certification record */
rk_ns_t_a6 = 38, /* IPv6 address (deprecates AAAA) */
rk_ns_t_dname = 39, /* Non-terminal DNAME (for IPv6) */
rk_ns_t_sink = 40, /* Kitchen sink (experimentatl) */
rk_ns_t_opt = 41, /* EDNS0 option (meta-RR) */
rk_ns_t_apl = 42, /* Address prefix list (RFC 3123) */
rk_ns_t_sshfp = 44, /* SSH fingerprint */
rk_ns_t_tkey = 249, /* Transaction key */
rk_ns_t_tsig = 250, /* Transaction signature. */
rk_ns_t_ixfr = 251, /* Incremental zone transfer. */
rk_ns_t_axfr = 252, /* Transfer zone of authority. */
rk_ns_t_mailb = 253, /* Transfer mailbox records. */
rk_ns_t_maila = 254, /* Transfer mail agent records. */
rk_ns_t_any = 255, /* Wildcard match. */
rk_ns_t_zxfr = 256, /* BIND-specific, nonstandard. */
rk_ns_t_max = 65536
} rk_ns_type;
/* We use these, but they are not always present in <arpa/nameser.h> */
#ifndef C_IN