dnsglue.c revision 159d09a20817016f09b3ea28d1bdada4a336bb91
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
*
* Copyright 2004 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
* require a specific license from the United States Government.
* It is the responsibility of any person or organization contemplating
* export to obtain such a license before exporting.
*
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
* distribute this software and its documentation for any purpose and
* without fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright notice and
* this permission notice appear in supporting documentation, and that
* the name of M.I.T. not be used in advertising or publicity pertaining
* to distribution of the software without specific, written prior
* permission. Furthermore if you modify this software you must label
* your software as modified software and not distribute it in such a
* fashion that it might be confused with the original M.I.T. software.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is" without express
* or implied warranty.
*
*/
#include "autoconf.h"
#ifdef KRB5_DNS_LOOKUP
#include "dnsglue.h"
/*
* Only use res_ninit() if there's also a res_ndestroy(), to avoid
* memory leaks (Linux & Solaris) and outright corruption (AIX 4.x,
* 5.x). While we're at it, make sure res_nsearch() is there too.
*
* In any case, it is probable that platforms having broken
* res_ninit() will have thread safety hacks for res_init() and _res.
*/
#define USE_RES_NINIT 1
#endif
/*
* Opaque handle
*/
struct krb5int_dns_state {
int nclass;
int ntype;
void *ansp;
int anslen;
int ansmax;
int cur_ans;
#else
unsigned char *ptr;
unsigned short nanswers;
#endif
};
#if !HAVE_NS_INITPARSE
static int initparse(struct krb5int_dns_state *);
#endif
/*
* krb5int_dns_init()
*
* Initialize an opaque handle. Do name lookup and initial parsing of
* reply, skipping question section. Prepare to iterate over answer
* section. Returns -1 on error, 0 on success.
*/
int
{
#if USE_RES_NINIT
struct __res_state statbuf;
#endif
struct krb5int_dns_state *ds;
unsigned char *p;
return -1;
ret = -1;
nextincr = 2048;
#endif
#if USE_RES_NINIT
#else
#endif
if (ret < 0)
return -1;
do {
ret = -1;
goto errout;
}
#if USE_RES_NINIT
#else
#endif
ret = -1;
goto errout;
}
nextincr *= 2;
ret = -1;
goto errout;
}
#else
#endif
if (ret < 0)
goto errout;
ret = 0;
#if USE_RES_NINIT
#endif
if (ret < 0) {
}
}
return ret;
}
/*
* krb5int_dns_nextans - get next matching answer record
*
* Sets pp to NULL if no more records. Returns -1 on error, 0 on
* success.
*/
int
{
int len;
*lenp = 0;
if (len < 0)
return -1;
return 0;
}
}
return 0;
}
#endif
/*
* krb5int_dns_expand - wrapper for dn_expand()
*/
const unsigned char *p,
{
#else
#endif
}
/*
* Free stuff.
*/
void
{
return;
}
/*
* Compat routines for BIND 4
*/
#if !HAVE_NS_INITPARSE
/*
* initparse
*
* Skip header and question section of reply. Set a pointer to the
* beginning of the answer section, and prepare to iterate over
* answer records.
*/
static int
{
unsigned char *p;
int len;
#if !HAVE_DN_SKIPNAME
#endif
return -1;
p += sizeof(HEADER);
/*
* Skip query records.
*/
while (nqueries--) {
#if HAVE_DN_SKIPNAME
#else
#endif
return -1;
p += len + 4;
}
return 0;
}
/*
* krb5int_dns_nextans() - get next answer record
*
* Sets pp to NULL if no more records.
*/
int
{
int len;
unsigned char *p;
#if !HAVE_DN_SKIPNAME
#endif
*lenp = 0;
#if HAVE_DN_SKIPNAME
#else
#endif
return -1;
p += len;
/* Also skip 4 bytes of TTL */
return -1;
/* Solaris Kerberos - resync */
#if 0
return -1;
#endif
*pp = p;
return 0;
}
p += rdlen;
}
return 0;
out:
return -1;
}
#endif
#endif /* KRB5_DNS_LOOKUP */