update to bind 4.9.3-p1.
This commit is contained in:
parent
5336dade8e
commit
32c0edb470
|
@ -1,37 +0,0 @@
|
|||
/*-
|
||||
* Copyright (c) 1990 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: @(#)pathnames.h 5.1 (Berkeley) 5/28/90
|
||||
* $Id: pathnames.h,v 1.2 1993/08/01 17:58:05 mycroft Exp $
|
||||
*/
|
||||
|
||||
#define _PATH_HELPFILE "/usr/share/misc/nslookup.help"
|
|
@ -1,148 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1985,1989 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: @(#)res.h 5.10 (Berkeley) 6/1/90
|
||||
* $Id: res.h,v 1.2 1993/08/01 17:58:03 mycroft Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* res.h --
|
||||
*
|
||||
* Definitions used by modules of the name server lookup program.
|
||||
*
|
||||
* Copyright (c) 1985
|
||||
* Andrew Cherenson
|
||||
* U.C. Berkeley
|
||||
* CS298-26 Fall 1985
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
typedef int Boolean;
|
||||
|
||||
/*
|
||||
* Define return statuses in addtion to the ones defined in namserv.h
|
||||
* let SUCCESS be a synonym for NOERROR
|
||||
*
|
||||
* TIME_OUT - a socket connection timed out.
|
||||
* NO_INFO - the server didn't find any info about the host.
|
||||
* ERROR - one of the following types of errors:
|
||||
* dn_expand, res_mkquery failed
|
||||
* bad command line, socket operation failed, etc.
|
||||
* NONAUTH - the server didn't have the desired info but
|
||||
* returned the name(s) of some servers who should.
|
||||
* NO_RESPONSE - the server didn't respond.
|
||||
*
|
||||
*/
|
||||
|
||||
#define SUCCESS 0
|
||||
#define TIME_OUT -1
|
||||
#define NO_INFO -2
|
||||
#define ERROR -3
|
||||
#define NONAUTH -4
|
||||
#define NO_RESPONSE -5
|
||||
|
||||
/*
|
||||
* Define additional options for the resolver state structure.
|
||||
*
|
||||
* RES_DEBUG2 more verbose debug level
|
||||
*/
|
||||
|
||||
#define RES_DEBUG2 0x80000000
|
||||
|
||||
/*
|
||||
* Maximum length of server, host and file names.
|
||||
*/
|
||||
|
||||
#define NAME_LEN 256
|
||||
|
||||
|
||||
/*
|
||||
* Modified struct hostent from <netdb.h>
|
||||
*
|
||||
* "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)."
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
char *name; /* official name of host */
|
||||
char **domains; /* domains it serves */
|
||||
char **addrList; /* list of addresses from name server */
|
||||
} ServerInfo;
|
||||
|
||||
typedef struct {
|
||||
char *name; /* official name of host */
|
||||
char **aliases; /* alias list */
|
||||
char **addrList; /* list of addresses from name server */
|
||||
int addrType; /* host address type */
|
||||
int addrLen; /* length of address */
|
||||
ServerInfo **servers;
|
||||
} HostInfo;
|
||||
|
||||
|
||||
/*
|
||||
* FilePtr is used for directing listings to a file.
|
||||
* It is global so the Control-C handler can close it.
|
||||
*/
|
||||
|
||||
extern FILE *filePtr;
|
||||
|
||||
/*
|
||||
* TCP/UDP port of server.
|
||||
*/
|
||||
extern unsigned short nsport;
|
||||
|
||||
/*
|
||||
* External routines:
|
||||
*/
|
||||
|
||||
extern Boolean IsAddr();
|
||||
extern int Print_query();
|
||||
extern char *Print_cdname();
|
||||
extern char *Print_cdname2(); /* fixed width */
|
||||
extern char *Print_rr();
|
||||
extern char *DecodeType(); /* descriptive version of p_type */
|
||||
extern char *DecodeError();
|
||||
extern char *Calloc();
|
||||
extern char *Malloc();
|
||||
extern void NsError();
|
||||
extern void PrintServer();
|
||||
extern void PrintHostInfo();
|
||||
extern void ShowOptions();
|
||||
extern void FreeHostInfoPtr();
|
||||
extern FILE *OpenFile();
|
||||
extern char *res_skip();
|
|
@ -1,564 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1985, 1989 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.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)send.c 5.18 (Berkeley) 3/2/91";*/
|
||||
static char rcsid[] = "$Id: send.c,v 1.2 1993/08/01 17:58:09 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* send.c --
|
||||
*
|
||||
* Routine to send request packets to a name server.
|
||||
*
|
||||
* Based on "@(#)res_send.c 6.25 (Berkeley) 6/1/90".
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Send query to name server and wait for reply.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
#include <netinet/in.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <resolv.h>
|
||||
#include "res.h"
|
||||
|
||||
extern int errno;
|
||||
|
||||
static int s = -1; /* socket used for communications */
|
||||
|
||||
|
||||
#ifndef FD_SET
|
||||
#define NFDBITS 32
|
||||
#define FD_SETSIZE 32
|
||||
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
|
||||
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
|
||||
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
|
||||
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
|
||||
#endif
|
||||
|
||||
#define SR 1 /* SendRequest style */
|
||||
|
||||
#ifndef DEBUG
|
||||
#define DEBUG
|
||||
#endif
|
||||
|
||||
unsigned short nsport = NAMESERVER_PORT;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* SendRequest --
|
||||
*
|
||||
* Sends a request packet to a name server whose address
|
||||
* is specified by the first argument and returns with
|
||||
* the answer packet.
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS - the request was sent and an answer
|
||||
* was received.
|
||||
* TIME_OUT - the virtual circuit connection timed-out
|
||||
* or a reply to a datagram wasn't received.
|
||||
*
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
int
|
||||
SendRequest(nsAddrPtr, buf, buflen, answer, anslen, trueLenPtr)
|
||||
struct in_addr *nsAddrPtr;
|
||||
char *buf;
|
||||
int buflen;
|
||||
char *answer;
|
||||
u_int anslen;
|
||||
int *trueLenPtr;
|
||||
{
|
||||
register int n;
|
||||
int try, v_circuit, resplen, ns;
|
||||
int gotsomewhere = 0, connected = 0;
|
||||
int connreset = 0;
|
||||
u_short id, len;
|
||||
char *cp;
|
||||
fd_set dsmask;
|
||||
struct timeval timeout;
|
||||
HEADER *hp = (HEADER *) buf;
|
||||
HEADER *anhp = (HEADER *) answer;
|
||||
struct iovec iov[2];
|
||||
int terrno = ETIMEDOUT;
|
||||
char junk[512];
|
||||
|
||||
#if SR
|
||||
struct sockaddr_in sin;
|
||||
|
||||
if (_res.options & RES_DEBUG2) {
|
||||
printf("------------\nSendRequest(), len %d\n", buflen);
|
||||
Print_query(buf, buf+buflen, 1);
|
||||
}
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(nsport);
|
||||
sin.sin_addr = *nsAddrPtr;
|
||||
#else
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG) {
|
||||
printf("res_send()\n");
|
||||
p_query(buf);
|
||||
}
|
||||
#endif DEBUG
|
||||
if (!(_res.options & RES_INIT))
|
||||
if (res_init() == -1) {
|
||||
return(-1);
|
||||
}
|
||||
#endif /* SR */
|
||||
v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ;
|
||||
id = hp->id;
|
||||
/*
|
||||
* Send request, RETRY times, or until successful
|
||||
*/
|
||||
for (try = 0; try < _res.retry; try++) {
|
||||
#if !SR
|
||||
for (ns = 0; ns < _res.nscount; ns++) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("Querying server (# %d) address = %s\n", ns+1,
|
||||
inet_ntoa(_res.nsaddr_list[ns].sin_addr));
|
||||
#endif DEBUG
|
||||
#endif /* !SR */
|
||||
usevc:
|
||||
if (v_circuit) {
|
||||
int truncated = 0;
|
||||
|
||||
/*
|
||||
* Use virtual circuit;
|
||||
* at most one attempt per server.
|
||||
*/
|
||||
try = _res.retry;
|
||||
if (s < 0) {
|
||||
s = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (s < 0) {
|
||||
terrno = errno;
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("socket (vc) failed");
|
||||
#endif DEBUG
|
||||
continue;
|
||||
}
|
||||
#if SR
|
||||
if (connect(s, (struct sockaddr *)&sin,
|
||||
#else
|
||||
if (connect(s,
|
||||
(struct sockaddr *)&(_res.nsaddr_list[ns]),
|
||||
#endif
|
||||
sizeof(struct sockaddr)) < 0) {
|
||||
terrno = errno;
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("connect failed");
|
||||
#endif DEBUG
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Send length & message
|
||||
*/
|
||||
len = htons((u_short)buflen);
|
||||
iov[0].iov_base = (caddr_t)&len;
|
||||
iov[0].iov_len = sizeof(len);
|
||||
iov[1].iov_base = buf;
|
||||
iov[1].iov_len = buflen;
|
||||
if (writev(s, iov, 2) != sizeof(len) + buflen) {
|
||||
terrno = errno;
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("write failed");
|
||||
#endif DEBUG
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Receive length & response
|
||||
*/
|
||||
cp = answer;
|
||||
len = sizeof(short);
|
||||
while (len != 0 &&
|
||||
(n = read(s, (char *)cp, (int)len)) > 0) {
|
||||
cp += n;
|
||||
len -= n;
|
||||
}
|
||||
if (n <= 0) {
|
||||
terrno = errno;
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("read failed");
|
||||
#endif DEBUG
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
/*
|
||||
* A long running process might get its TCP
|
||||
* connection reset if the remote server was
|
||||
* restarted. Requery the server instead of
|
||||
* trying a new one. When there is only one
|
||||
* server, this means that a query might work
|
||||
* instead of failing. We only allow one reset
|
||||
* per query to prevent looping.
|
||||
*/
|
||||
if (terrno == ECONNRESET && !connreset) {
|
||||
connreset = 1;
|
||||
ns--;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
cp = answer;
|
||||
if ((resplen = ntohs(*(u_short *)cp)) > anslen) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
fprintf(stderr, "response truncated\n");
|
||||
#endif DEBUG
|
||||
len = anslen;
|
||||
truncated = 1;
|
||||
} else
|
||||
len = resplen;
|
||||
while (len != 0 &&
|
||||
(n = read(s, (char *)cp, (int)len)) > 0) {
|
||||
cp += n;
|
||||
len -= n;
|
||||
}
|
||||
if (n <= 0) {
|
||||
terrno = errno;
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("read failed");
|
||||
#endif DEBUG
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
continue;
|
||||
}
|
||||
if (truncated) {
|
||||
/*
|
||||
* Flush rest of answer
|
||||
* so connection stays in synch.
|
||||
*/
|
||||
anhp->tc = 1;
|
||||
len = resplen - anslen;
|
||||
while (len != 0) {
|
||||
n = (len > sizeof(junk) ?
|
||||
sizeof(junk) : len);
|
||||
if ((n = read(s, junk, n)) > 0)
|
||||
len -= n;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Use datagrams.
|
||||
*/
|
||||
if (s < 0) {
|
||||
s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s < 0) {
|
||||
terrno = errno;
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("socket (dg) failed");
|
||||
#endif DEBUG
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#if SR
|
||||
/*
|
||||
* Special case the send code below
|
||||
* since we have just 1 server.
|
||||
*/
|
||||
#if BSD >= 43
|
||||
if (connected == 0) {
|
||||
if (connect(s, (struct sockaddr *)&sin,
|
||||
sizeof(struct sockaddr)) < 0) {
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("connect");
|
||||
continue;
|
||||
}
|
||||
connected = 1;
|
||||
}
|
||||
if (send(s, buf, buflen, 0) != buflen) {
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("send");
|
||||
continue;
|
||||
}
|
||||
#else /* BSD */
|
||||
if (sendto(s, buf, buflen, 0, &sin,
|
||||
sizeof(struct sockaddr)) != buflen) {
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("sendto");
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
#else /* SR */
|
||||
#if BSD >= 43
|
||||
/*
|
||||
* I'm tired of answering this question, so:
|
||||
* On a 4.3BSD+ machine (client and server,
|
||||
* actually), sending to a nameserver datagram
|
||||
* port with no nameserver will cause an
|
||||
* ICMP port unreachable message to be returned.
|
||||
* If our datagram socket is "connected" to the
|
||||
* server, we get an ECONNREFUSED error on the next
|
||||
* socket operation, and select returns if the
|
||||
* error message is received. We can thus detect
|
||||
* the absence of a nameserver without timing out.
|
||||
* If we have sent queries to at least two servers,
|
||||
* however, we don't want to remain connected,
|
||||
* as we wish to receive answers from the first
|
||||
* server to respond.
|
||||
*/
|
||||
if (_res.nscount == 1 || (try == 0 && ns == 0)) {
|
||||
/*
|
||||
* Don't use connect if we might
|
||||
* still receive a response
|
||||
* from another server.
|
||||
*/
|
||||
if (connected == 0) {
|
||||
if (connect(s, &_res.nsaddr_list[ns],
|
||||
sizeof(struct sockaddr)) < 0) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("connect");
|
||||
#endif DEBUG
|
||||
continue;
|
||||
}
|
||||
connected = 1;
|
||||
}
|
||||
if (send(s, buf, buflen, 0) != buflen) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("send");
|
||||
#endif DEBUG
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Disconnect if we want to listen
|
||||
* for responses from more than one server.
|
||||
*/
|
||||
if (connected) {
|
||||
(void) connect(s, &no_addr,
|
||||
sizeof(no_addr));
|
||||
connected = 0;
|
||||
}
|
||||
#endif BSD
|
||||
if (sendto(s, buf, buflen, 0,
|
||||
&_res.nsaddr_list[ns],
|
||||
sizeof(struct sockaddr)) != buflen) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("sendto");
|
||||
#endif DEBUG
|
||||
continue;
|
||||
}
|
||||
#if BSD >= 43
|
||||
}
|
||||
#endif
|
||||
#endif /* SR */
|
||||
|
||||
/*
|
||||
* Wait for reply
|
||||
*/
|
||||
timeout.tv_sec = (_res.retrans << try);
|
||||
#if !SR
|
||||
if (try > 0)
|
||||
timeout.tv_sec /= _res.nscount;
|
||||
#endif /* SR */
|
||||
if (timeout.tv_sec <= 0)
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
wait:
|
||||
FD_ZERO(&dsmask);
|
||||
FD_SET(s, &dsmask);
|
||||
n = select(s+1, &dsmask, (fd_set *)NULL,
|
||||
(fd_set *)NULL, &timeout);
|
||||
if (n < 0) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("select");
|
||||
#endif DEBUG
|
||||
continue;
|
||||
}
|
||||
if (n == 0) {
|
||||
/*
|
||||
* timeout
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("timeout (%d secs)\n",
|
||||
timeout.tv_sec);
|
||||
#endif DEBUG
|
||||
#if BSD >= 43
|
||||
gotsomewhere = 1;
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
if ((resplen = recv(s, answer, anslen, 0)) <= 0) {
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("recvfrom");
|
||||
#endif DEBUG
|
||||
continue;
|
||||
}
|
||||
gotsomewhere = 1;
|
||||
if (id != anhp->id) {
|
||||
/*
|
||||
* response from old query, ignore it
|
||||
*/
|
||||
#if SR
|
||||
if (_res.options & RES_DEBUG2) {
|
||||
printf("------------\nOld answer:\n");
|
||||
Print_query(answer, answer+resplen, 1);
|
||||
}
|
||||
#else
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG) {
|
||||
printf("old answer:\n");
|
||||
p_query(answer);
|
||||
}
|
||||
#endif DEBUG
|
||||
#endif
|
||||
goto wait;
|
||||
}
|
||||
if (!(_res.options & RES_IGNTC) && anhp->tc) {
|
||||
/*
|
||||
* get rest of answer;
|
||||
* use TCP with same server.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("truncated answer\n");
|
||||
#endif DEBUG
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
v_circuit = 1;
|
||||
goto usevc;
|
||||
}
|
||||
}
|
||||
#if SR
|
||||
if (_res.options & RES_DEBUG) {
|
||||
if (_res.options & RES_DEBUG2)
|
||||
printf("------------\nGot answer (%d bytes):\n",
|
||||
resplen);
|
||||
else
|
||||
printf("------------\nGot answer:\n");
|
||||
Print_query(answer, answer+resplen, 1);
|
||||
}
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
*trueLenPtr = resplen;
|
||||
return (SUCCESS);
|
||||
#else
|
||||
#ifdef DEBUG
|
||||
if (_res.options & RES_DEBUG) {
|
||||
printf("got answer:\n");
|
||||
p_query(answer);
|
||||
}
|
||||
#endif DEBUG
|
||||
/*
|
||||
* If using virtual circuits, we assume that the first server
|
||||
* is preferred * over the rest (i.e. it is on the local
|
||||
* machine) and only keep that one open.
|
||||
* If we have temporarily opened a virtual circuit,
|
||||
* or if we haven't been asked to keep a socket open,
|
||||
* close the socket.
|
||||
*/
|
||||
if ((v_circuit &&
|
||||
((_res.options & RES_USEVC) == 0 || ns != 0)) ||
|
||||
(_res.options & RES_STAYOPEN) == 0) {
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
}
|
||||
return (resplen);
|
||||
}
|
||||
#endif /* SR */
|
||||
}
|
||||
if (s >= 0) {
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
}
|
||||
#if SR
|
||||
if (v_circuit == 0)
|
||||
if (gotsomewhere == 0)
|
||||
return NO_RESPONSE; /* no nameservers found */
|
||||
else
|
||||
return TIME_OUT; /* no answer obtained */
|
||||
else
|
||||
if (errno == ECONNREFUSED)
|
||||
return NO_RESPONSE;
|
||||
else
|
||||
return ERROR;
|
||||
#else
|
||||
if (v_circuit == 0)
|
||||
if (gotsomewhere == 0)
|
||||
errno = ECONNREFUSED; /* no nameservers found */
|
||||
else
|
||||
errno = ETIMEDOUT; /* no answer obtained */
|
||||
else
|
||||
errno = terrno;
|
||||
return (-1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine is for closing the socket if a virtual circuit is used and
|
||||
* the program wants to close it.
|
||||
*
|
||||
* Called from the interrupt handler.
|
||||
*/
|
||||
SendRequest_close()
|
||||
{
|
||||
if (s != -1) {
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
}
|
||||
}
|
|
@ -1,188 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1985 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.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)skip.c 5.12 (Berkeley) 3/21/91";*/
|
||||
static char rcsid[] = "$Id: skip.c,v 1.2 1993/08/01 17:58:07 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* skip.c --
|
||||
*
|
||||
* Routines to skip over portions of a query buffer.
|
||||
*
|
||||
* Note: this file has been submitted for inclusion in
|
||||
* BIND resolver library. When this has been done, this file
|
||||
* is no longer necessary (assuming there haven't been any
|
||||
* changes).
|
||||
*
|
||||
* Adapted from 4.3BSD BIND res_debug.c
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char *res_skip_rr();
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* res_skip --
|
||||
*
|
||||
* Skip the contents of a query.
|
||||
*
|
||||
* Interpretation of numFieldsToSkip argument:
|
||||
* res_skip returns pointer to:
|
||||
* 1 -> start of question records.
|
||||
* 2 -> start of authoritative answer records.
|
||||
* 3 -> start of additional records.
|
||||
* 4 -> first byte after end of additional records.
|
||||
*
|
||||
* Results:
|
||||
* (address) - success operation.
|
||||
* NULL - a resource record had an incorrect format.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
char *
|
||||
res_skip(msg, numFieldsToSkip, eom)
|
||||
char *msg;
|
||||
int numFieldsToSkip;
|
||||
char *eom;
|
||||
{
|
||||
register char *cp;
|
||||
register HEADER *hp;
|
||||
register int tmp;
|
||||
register int n;
|
||||
|
||||
/*
|
||||
* Skip the header fields.
|
||||
*/
|
||||
hp = (HEADER *)msg;
|
||||
cp = msg + sizeof(HEADER);
|
||||
|
||||
/*
|
||||
* skip question records.
|
||||
*/
|
||||
if (n = ntohs(hp->qdcount) ) {
|
||||
while (--n >= 0 && cp < eom) {
|
||||
tmp = dn_skipname((u_char *)cp, (u_char *)eom);
|
||||
if (tmp == -1) return(NULL);
|
||||
cp += tmp;
|
||||
cp += sizeof(u_short); /* type */
|
||||
cp += sizeof(u_short); /* class */
|
||||
}
|
||||
}
|
||||
if (--numFieldsToSkip <= 0) return(cp);
|
||||
|
||||
/*
|
||||
* skip authoritative answer records
|
||||
*/
|
||||
if (n = ntohs(hp->ancount)) {
|
||||
while (--n >= 0 && cp < eom) {
|
||||
cp = res_skip_rr(cp, eom);
|
||||
if (cp == NULL) return(NULL);
|
||||
}
|
||||
}
|
||||
if (--numFieldsToSkip == 0) return(cp);
|
||||
|
||||
/*
|
||||
* skip name server records
|
||||
*/
|
||||
if (n = ntohs(hp->nscount)) {
|
||||
while (--n >= 0 && cp < eom) {
|
||||
cp = res_skip_rr(cp, eom);
|
||||
if (cp == NULL) return(NULL);
|
||||
}
|
||||
}
|
||||
if (--numFieldsToSkip == 0) return(cp);
|
||||
|
||||
/*
|
||||
* skip additional records
|
||||
*/
|
||||
if (n = ntohs(hp->arcount)) {
|
||||
while (--n >= 0 && cp < eom) {
|
||||
cp = res_skip_rr(cp, eom);
|
||||
if (cp == NULL) return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return(cp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* res_skip_rr --
|
||||
*
|
||||
* Skip over resource record fields.
|
||||
*
|
||||
* Results:
|
||||
* (address) - success operation.
|
||||
* NULL - a resource record had an incorrect format.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
char *
|
||||
res_skip_rr(cp, eom)
|
||||
char *cp;
|
||||
char *eom;
|
||||
{
|
||||
int tmp;
|
||||
int dlen;
|
||||
|
||||
if ((tmp = dn_skipname((u_char *)cp, (u_char *)eom)) == -1)
|
||||
return (NULL); /* compression error */
|
||||
cp += tmp;
|
||||
if ((cp + RRFIXEDSZ) > eom)
|
||||
return (NULL);
|
||||
cp += sizeof(u_short); /* type */
|
||||
cp += sizeof(u_short); /* class */
|
||||
cp += sizeof(u_long); /* ttl */
|
||||
dlen = _getshort(cp);
|
||||
cp += sizeof(u_short); /* dlen */
|
||||
cp += dlen;
|
||||
if (cp > eom)
|
||||
return (NULL);
|
||||
return (cp);
|
||||
}
|
|
@ -1,510 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1985,1989 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.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)subr.c 5.24 (Berkeley) 3/2/91";*/
|
||||
static char rcsid[] = "$Id: subr.c,v 1.2 1993/08/01 17:58:06 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* subr.c --
|
||||
*
|
||||
* Miscellaneous subroutines for the name server
|
||||
* lookup program.
|
||||
*
|
||||
* Copyright (c) 1985
|
||||
* Andrew Cherenson
|
||||
* U.C. Berkeley
|
||||
* CS298-26 Fall 1985
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <signal.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "res.h"
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* IntrHandler --
|
||||
*
|
||||
* This routine is called whenever a control-C is typed.
|
||||
* It performs three main functions:
|
||||
* - closes an open socket connection,
|
||||
* - closes an open output file (used by LookupHost, et al.),
|
||||
* - jumps back to the main read-eval loop.
|
||||
*
|
||||
* If a user types a ^C in the middle of a routine that uses a socket,
|
||||
* the routine would not be able to close the socket. To prevent an
|
||||
* overflow of the process's open file table, the socket and output
|
||||
* file descriptors are closed by the interrupt handler.
|
||||
*
|
||||
* Side effects:
|
||||
* Open file descriptors are closed.
|
||||
* If filePtr is valid, it is closed.
|
||||
* Flow of control returns to the main() routine.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void
|
||||
IntrHandler()
|
||||
{
|
||||
extern jmp_buf env;
|
||||
#if defined(BSD) && BSD >= 199006
|
||||
extern FILE *yyin; /* scanner input file */
|
||||
extern void yyrestart(); /* routine to restart scanner after interrupt */
|
||||
#endif
|
||||
|
||||
SendRequest_close();
|
||||
ListHost_close();
|
||||
if (filePtr != NULL && filePtr != stdout) {
|
||||
fclose(filePtr);
|
||||
filePtr = NULL;
|
||||
}
|
||||
printf("\n");
|
||||
#if defined(BSD) && BSD >= 199006
|
||||
yyrestart(yyin);
|
||||
#endif
|
||||
longjmp(env, 1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Malloc --
|
||||
* Calloc --
|
||||
*
|
||||
* Calls the malloc library routine with SIGINT blocked to prevent
|
||||
* corruption of malloc's data structures. We need to do this because
|
||||
* a control-C doesn't kill the program -- it causes a return to the
|
||||
* main command loop.
|
||||
*
|
||||
* NOTE: This method doesn't prevent the pointer returned by malloc
|
||||
* from getting lost, so it is possible to get "core leaks".
|
||||
*
|
||||
* If malloc fails, the program exits.
|
||||
*
|
||||
* Results:
|
||||
* (address) - address of new buffer.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
char *
|
||||
Malloc(size)
|
||||
int size;
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
#ifdef SYSV
|
||||
#ifdef SVR3
|
||||
sighold(SIGINT);
|
||||
ptr = malloc((unsigned) size);
|
||||
sigrelse(SIGINT);
|
||||
#else
|
||||
{ int (*old)();
|
||||
old = signal(SIGINT, SIG_IGN);
|
||||
ptr = malloc((unsigned) size);
|
||||
signal(SIGINT, old);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
{ int saveMask;
|
||||
saveMask = sigblock(sigmask(SIGINT));
|
||||
ptr = malloc((unsigned) size);
|
||||
(void) sigsetmask(saveMask);
|
||||
}
|
||||
#endif
|
||||
if (ptr == NULL) {
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "*** Can't allocate memory\n");
|
||||
fflush(stderr);
|
||||
abort();
|
||||
/*NOTREACHED*/
|
||||
} else {
|
||||
return(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
Calloc(num, size)
|
||||
register int num, size;
|
||||
{
|
||||
char *ptr = Malloc(num*size);
|
||||
bzero(ptr, num*size);
|
||||
return(ptr);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* PrintHostInfo --
|
||||
*
|
||||
* Prints out the HostInfo structure for a host.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void
|
||||
PrintHostInfo(file, title, hp)
|
||||
FILE *file;
|
||||
char *title;
|
||||
register HostInfo *hp;
|
||||
{
|
||||
register char **cp;
|
||||
register ServerInfo **sp;
|
||||
char comma;
|
||||
int i;
|
||||
|
||||
fprintf(file, "%-7s %s", title, hp->name);
|
||||
|
||||
if (hp->addrList != NULL) {
|
||||
if (hp->addrList[1] != NULL) {
|
||||
fprintf(file, "\nAddresses:");
|
||||
} else {
|
||||
fprintf(file, "\nAddress:");
|
||||
}
|
||||
comma = ' ';
|
||||
i = 0;
|
||||
for (cp = hp->addrList; cp && *cp; cp++) {
|
||||
i++;
|
||||
if (i > 4) {
|
||||
fprintf(file, "\n\t");
|
||||
comma = ' ';
|
||||
i = 0;
|
||||
}
|
||||
fprintf(file,"%c %s", comma, inet_ntoa(*(struct in_addr *)*cp));
|
||||
comma = ',';
|
||||
}
|
||||
}
|
||||
|
||||
if (hp->aliases != NULL) {
|
||||
fprintf(file, "\nAliases:");
|
||||
comma = ' ';
|
||||
i = 10;
|
||||
for (cp = hp->aliases; cp && *cp && **cp; cp++) {
|
||||
i += strlen(*cp) + 2;
|
||||
if (i > 75) {
|
||||
fprintf(file, "\n\t");
|
||||
comma = ' ';
|
||||
i = 10;
|
||||
}
|
||||
fprintf(file, "%c %s", comma, *cp);
|
||||
comma = ',';
|
||||
}
|
||||
}
|
||||
|
||||
if (hp->servers != NULL) {
|
||||
fprintf(file, "\nServed by:\n");
|
||||
for (sp = hp->servers; *sp != NULL ; sp++) {
|
||||
|
||||
fprintf(file, "- %s\n\t", (*sp)->name);
|
||||
|
||||
comma = ' ';
|
||||
i = 0;
|
||||
for (cp = (*sp)->addrList; cp && *cp && **cp; cp++) {
|
||||
i++;
|
||||
if (i > 4) {
|
||||
fprintf(file, "\n\t");
|
||||
comma = ' ';
|
||||
i = 0;
|
||||
}
|
||||
fprintf(file,
|
||||
"%c %s", comma, inet_ntoa(*(struct in_addr *)*cp));
|
||||
comma = ',';
|
||||
}
|
||||
fprintf(file, "\n\t");
|
||||
|
||||
comma = ' ';
|
||||
i = 10;
|
||||
for (cp = (*sp)->domains; cp && *cp && **cp; cp++) {
|
||||
i += strlen(*cp) + 2;
|
||||
if (i > 75) {
|
||||
fprintf(file, "\n\t");
|
||||
comma = ' ';
|
||||
i = 10;
|
||||
}
|
||||
fprintf(file, "%c %s", comma, *cp);
|
||||
comma = ',';
|
||||
}
|
||||
fprintf(file, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(file, "\n\n");
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* OpenFile --
|
||||
*
|
||||
* Parses a command string for a file name and opens
|
||||
* the file.
|
||||
*
|
||||
* Results:
|
||||
* file pointer - the open was successful.
|
||||
* NULL - there was an error opening the file or
|
||||
* the input string was invalid.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
FILE *
|
||||
OpenFile(string, file)
|
||||
char *string;
|
||||
char *file;
|
||||
{
|
||||
char *redirect;
|
||||
FILE *tmpPtr;
|
||||
|
||||
/*
|
||||
* Open an output file if we see '>' or >>'.
|
||||
* Check for overwrite (">") or concatenation (">>").
|
||||
*/
|
||||
|
||||
redirect = strchr(string, '>');
|
||||
if (redirect == NULL) {
|
||||
return(NULL);
|
||||
}
|
||||
if (redirect[1] == '>') {
|
||||
sscanf(redirect, ">> %s", file);
|
||||
tmpPtr = fopen(file, "a+");
|
||||
} else {
|
||||
sscanf(redirect, "> %s", file);
|
||||
tmpPtr = fopen(file, "w");
|
||||
}
|
||||
|
||||
if (tmpPtr != NULL) {
|
||||
redirect[0] = '\0';
|
||||
}
|
||||
|
||||
return(tmpPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* DecodeError --
|
||||
*
|
||||
* Converts an error code into a character string.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
char *
|
||||
DecodeError(result)
|
||||
int result;
|
||||
{
|
||||
switch (result) {
|
||||
case NOERROR: return("Success"); break;
|
||||
case FORMERR: return("Format error"); break;
|
||||
case SERVFAIL: return("Server failed"); break;
|
||||
case NXDOMAIN: return("Non-existent domain"); break;
|
||||
case NOTIMP: return("Not implemented"); break;
|
||||
case REFUSED: return("Query refused"); break;
|
||||
case NOCHANGE: return("No change"); break;
|
||||
case TIME_OUT: return("Timed out"); break;
|
||||
case NO_INFO: return("No information"); break;
|
||||
case ERROR: return("Unspecified error"); break;
|
||||
case NONAUTH: return("Non-authoritative answer"); break;
|
||||
case NO_RESPONSE: return("No response from server"); break;
|
||||
default: break;
|
||||
}
|
||||
return("BAD ERROR VALUE");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
StringToClass(class, dflt)
|
||||
char *class;
|
||||
int dflt;
|
||||
{
|
||||
if (strcasecmp(class, "IN") == 0)
|
||||
return(C_IN);
|
||||
if (strcasecmp(class, "HESIOD") == 0 ||
|
||||
strcasecmp(class, "HS") == 0)
|
||||
return(C_HS);
|
||||
if (strcasecmp(class, "CHAOS") == 0)
|
||||
return(C_CHAOS);
|
||||
if (strcasecmp(class, "ANY") == 0)
|
||||
return(C_ANY);
|
||||
fprintf(stderr, "unknown query class: %s\n", class);
|
||||
return(dflt);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* StringToType --
|
||||
*
|
||||
* Converts a string form of a query type name to its
|
||||
* corresponding integer value.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
int
|
||||
StringToType(type, dflt)
|
||||
char *type;
|
||||
int dflt;
|
||||
{
|
||||
if (strcasecmp(type, "A") == 0)
|
||||
return(T_A);
|
||||
if (strcasecmp(type, "NS") == 0)
|
||||
return(T_NS); /* authoritative server */
|
||||
if (strcasecmp(type, "MX") == 0)
|
||||
return(T_MX); /* mail exchanger */
|
||||
if (strcasecmp(type, "CNAME") == 0)
|
||||
return(T_CNAME); /* canonical name */
|
||||
if (strcasecmp(type, "SOA") == 0)
|
||||
return(T_SOA); /* start of authority zone */
|
||||
if (strcasecmp(type, "MB") == 0)
|
||||
return(T_MB); /* mailbox domain name */
|
||||
if (strcasecmp(type, "MG") == 0)
|
||||
return(T_MG); /* mail group member */
|
||||
if (strcasecmp(type, "MR") == 0)
|
||||
return(T_MR); /* mail rename name */
|
||||
if (strcasecmp(type, "WKS") == 0)
|
||||
return(T_WKS); /* well known service */
|
||||
if (strcasecmp(type, "PTR") == 0)
|
||||
return(T_PTR); /* domain name pointer */
|
||||
if (strcasecmp(type, "HINFO") == 0)
|
||||
return(T_HINFO); /* host information */
|
||||
if (strcasecmp(type, "MINFO") == 0)
|
||||
return(T_MINFO); /* mailbox information */
|
||||
if (strcasecmp(type, "AXFR") == 0)
|
||||
return(T_AXFR); /* zone transfer */
|
||||
if (strcasecmp(type, "MAILA") == 0)
|
||||
return(T_MAILA); /* mail agent */
|
||||
if (strcasecmp(type, "MAILB") == 0)
|
||||
return(T_MAILB); /* mail box */
|
||||
if (strcasecmp(type, "ANY") == 0)
|
||||
return(T_ANY); /* matches any type */
|
||||
if (strcasecmp(type, "UINFO") == 0)
|
||||
return(T_UINFO); /* user info */
|
||||
if (strcasecmp(type, "UID") == 0)
|
||||
return(T_UID); /* user id */
|
||||
if (strcasecmp(type, "GID") == 0)
|
||||
return(T_GID); /* group id */
|
||||
if (strcasecmp(type, "TXT") == 0)
|
||||
return(T_TXT); /* text */
|
||||
fprintf(stderr, "unknown query type: %s\n", type);
|
||||
return(dflt);
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* DecodeType --
|
||||
*
|
||||
* Converts a query type to a descriptive name.
|
||||
* (A more verbose form of p_type.)
|
||||
*
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
static char nbuf[20];
|
||||
|
||||
char *
|
||||
DecodeType(type)
|
||||
int type;
|
||||
{
|
||||
switch (type) {
|
||||
case T_A:
|
||||
return("address");
|
||||
case T_NS:
|
||||
return("name server");
|
||||
case T_CNAME:
|
||||
return("canonical name");
|
||||
case T_SOA:
|
||||
return("start of authority");
|
||||
case T_MB:
|
||||
return("mailbox");
|
||||
case T_MG:
|
||||
return("mail group member");
|
||||
case T_MR:
|
||||
return("mail rename");
|
||||
case T_NULL:
|
||||
return("null");
|
||||
case T_WKS:
|
||||
return("well-known service");
|
||||
case T_PTR:
|
||||
return("domain name pointer");
|
||||
case T_HINFO:
|
||||
return("host information");
|
||||
case T_MINFO:
|
||||
return("mailbox information");
|
||||
case T_MX:
|
||||
return("mail exchanger");
|
||||
case T_TXT:
|
||||
return("text");
|
||||
case T_UINFO:
|
||||
return("user information");
|
||||
case T_UID:
|
||||
return("user ID");
|
||||
case T_GID:
|
||||
return("group ID");
|
||||
case T_AXFR:
|
||||
return("zone transfer");
|
||||
case T_MAILB:
|
||||
return("mailbox-related data");
|
||||
case T_MAILA:
|
||||
return("mail agent");
|
||||
case T_ANY:
|
||||
return("\"any\"");
|
||||
default:
|
||||
(void) sprintf(nbuf, "%d", type);
|
||||
return (nbuf);
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
# from: @(#)Makefile 5.1 (Berkeley) 5/28/90
|
||||
# $Id: Makefile,v 1.2 1993/07/30 21:41:41 mycroft Exp $
|
||||
|
||||
PROG= nsquery
|
||||
NOMAN= noman
|
||||
|
||||
.include "../../../Makefile.inc"
|
||||
.include <bsd.prog.mk>
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1986 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.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
char copyright[] =
|
||||
"@(#) Copyright (c) 1986 Regents of the University of California.\n\
|
||||
All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)nsquery.c 4.8 (Berkeley) 6/1/90";*/
|
||||
static char rcsid[] = "$Id: nsquery.c,v 1.3 1994/03/24 07:56:31 deraadt Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
register struct hostent *hp;
|
||||
register char *s;
|
||||
|
||||
if (argc >= 2 && strcmp(argv[1], "-d") == 0) {
|
||||
_res.options |= RES_DEBUG;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "usage: nsquery [-d] host [server]\n");
|
||||
exit(1);
|
||||
}
|
||||
if (argc == 3) {
|
||||
hp = gethostbyname(argv[2]);
|
||||
if (hp == NULL) {
|
||||
fprintf(stderr, "nsquery:");
|
||||
herror(argv[2]);
|
||||
exit(1);
|
||||
}
|
||||
printf("\nServer:\n");
|
||||
printanswer(hp);
|
||||
_res.nsaddr.sin_addr = *(struct in_addr *)hp->h_addr;
|
||||
}
|
||||
|
||||
hp = gethostbyname(argv[1]);
|
||||
if (hp == NULL) {
|
||||
fprintf(stderr, "nsquery: %s: ", argv[1]);
|
||||
herror((char *)NULL);
|
||||
exit(1);
|
||||
}
|
||||
printanswer(hp);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printanswer(hp)
|
||||
register struct hostent *hp;
|
||||
{
|
||||
register char **cp;
|
||||
extern char *inet_ntoa();
|
||||
|
||||
printf("Name: %s\n", hp->h_name);
|
||||
#if BSD >= 43 || defined(h_addr)
|
||||
printf("Addresses:");
|
||||
for (cp = hp->h_addr_list; cp && *cp; cp++)
|
||||
printf(" %s", inet_ntoa(*(struct in_addr *)(*cp)));
|
||||
printf("\n");
|
||||
#else
|
||||
printf("Address: %s\n", inet_ntoa(*(struct in_addr *)hp->h_addr));
|
||||
#endif
|
||||
printf("Aliases:");
|
||||
for (cp = hp->h_aliases; cp && *cp && **cp; cp++)
|
||||
printf(" %s", *cp);
|
||||
printf("\n\n");
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
# from: @(#)Makefile 5.1 (Berkeley) 5/28/90
|
||||
# $Id: Makefile,v 1.2 1993/07/30 21:41:35 mycroft Exp $
|
||||
|
||||
PROG= nstest
|
||||
NOMAN= noman
|
||||
|
||||
.include "../../../Makefile.inc"
|
||||
.include <bsd.prog.mk>
|
|
@ -1,389 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 1986, 1989 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.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
char copyright[] =
|
||||
"@(#) Copyright (c) 1986 Regents of the University of California.\n\
|
||||
All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)nstest.c 4.15 (Berkeley) 3/21/91";*/
|
||||
static char rcsid[] = "$Id: nstest.c,v 1.3 1994/12/23 16:55:50 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
extern char *inet_ntoa();
|
||||
char *progname;
|
||||
FILE *log;
|
||||
#define MAXDATA 256 /* really should get definition from named/db.h */
|
||||
main(argc, argv)
|
||||
char **argv;
|
||||
{
|
||||
register char *cp;
|
||||
struct hostent *hp;
|
||||
u_short port = htons(NAMESERVER_PORT);
|
||||
char buf[BUFSIZ];
|
||||
char packet[PACKETSZ];
|
||||
char answer[PACKETSZ];
|
||||
struct rrec NewRR;
|
||||
char OldRRData[MAXDATA];
|
||||
int n, dump_packet;
|
||||
|
||||
NewRR.r_data = (char *) malloc(MAXDATA);
|
||||
NewRR.r_data = (char *) malloc(MAXDATA);
|
||||
progname = argv[0];
|
||||
dump_packet = 0;
|
||||
_res.options |= RES_DEBUG|RES_RECURSE;
|
||||
(void) res_init();
|
||||
while (argc > 1 && argv[1][0] == '-') {
|
||||
argc--;
|
||||
cp = *++argv;
|
||||
while (*++cp)
|
||||
switch (*cp) {
|
||||
case 'p':
|
||||
if (--argc <= 0)
|
||||
usage();
|
||||
port = htons(atoi(*++argv));
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
_res.options |= RES_IGNTC;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
_res.options |= RES_USEVC|RES_STAYOPEN;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
_res.options &= ~RES_RECURSE;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
dump_packet++;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
_res.nsaddr.sin_family = AF_INET;
|
||||
_res.nsaddr.sin_addr.s_addr = INADDR_ANY;
|
||||
_res.nsaddr.sin_port = port;
|
||||
if (argc > 1) {
|
||||
_res.nsaddr.sin_addr.s_addr = inet_addr(argv[1]);
|
||||
if (_res.nsaddr.sin_addr.s_addr == (u_long) -1)
|
||||
usage();
|
||||
}
|
||||
if (argc > 2) {
|
||||
log = fopen(argv[2],"w");
|
||||
if (log == NULL) perror(argv[2]);
|
||||
}
|
||||
for (;;) {
|
||||
printf("> ");
|
||||
fflush(stdout);
|
||||
if ((cp = (char *)gets(buf)) == NULL)
|
||||
break;
|
||||
switch (*cp++) {
|
||||
case 'a':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_A, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'A':
|
||||
n = ntohl(inet_addr(cp));
|
||||
putlong((u_long)n, (u_char *)cp);
|
||||
n = res_mkquery(IQUERY, "", C_IN, T_A, cp, sizeof(long),
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
n = res_mkquery(QUERY, cp, C_ANY, T_UINFO, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
n = res_mkquery(QUERY, cp, C_ANY, T_GID, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'G':
|
||||
*(int *)cp = htonl(atoi(cp));
|
||||
n = res_mkquery(IQUERY, "", C_ANY, T_GID, cp,
|
||||
sizeof(int), NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_CNAME, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_HINFO, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_MX, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_MAILB, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_NS, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_PTR, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 's':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_SOA, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_TXT, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
n = res_mkquery(QUERY, cp, C_ANY, T_UID, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'U':
|
||||
*(int *)cp = htonl(atoi(cp));
|
||||
n = res_mkquery(IQUERY, "", C_ANY, T_UID, cp,
|
||||
sizeof(int), NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_AXFR, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_WKS, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_MB, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_MG, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_MINFO, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_MR, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case '*':
|
||||
n = res_mkquery(QUERY, cp, C_IN, T_ANY, (char *)0, 0,
|
||||
NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
#ifdef ALLOW_UPDATES
|
||||
case '^':
|
||||
{
|
||||
char IType[10], TempStr[50];
|
||||
int Type, oldnbytes, nbytes, i;
|
||||
#ifdef ALLOW_T_UNSPEC
|
||||
printf("Data type (a = T_A, u = T_UNSPEC): ");
|
||||
gets(IType);
|
||||
if (IType[0] == 'u') {
|
||||
Type = T_UNSPEC;
|
||||
printf("How many data bytes? ");
|
||||
gets(TempStr); /* Throw away CR */
|
||||
sscanf(TempStr, "%d", &nbytes);
|
||||
for (i = 0; i < nbytes; i++) {
|
||||
(NewRR.r_data)[i] = (char) i;
|
||||
}
|
||||
} else {
|
||||
#endif ALLOW_T_UNSPEC
|
||||
Type = T_A;
|
||||
nbytes = sizeof(u_long);
|
||||
printf("Inet addr for new dname (e.g., 192.4.3.2): ");
|
||||
gets(TempStr);
|
||||
putlong(ntohl(inet_addr(TempStr)),
|
||||
NewRR.r_data);
|
||||
#ifdef ALLOW_T_UNSPEC
|
||||
}
|
||||
#endif ALLOW_T_UNSPEC
|
||||
NewRR.r_class = C_IN;
|
||||
NewRR.r_type = Type;
|
||||
NewRR.r_size = nbytes;
|
||||
NewRR.r_ttl = 99999999;
|
||||
printf("Add, modify, or modify all (a/m/M)? ");
|
||||
gets(TempStr);
|
||||
if (TempStr[0] == 'a') {
|
||||
n = res_mkquery(UPDATEA, cp, C_IN, Type,
|
||||
OldRRData, nbytes,
|
||||
&NewRR, packet,
|
||||
sizeof(packet));
|
||||
} else {
|
||||
if (TempStr[0] == 'm') {
|
||||
printf("How many data bytes in old RR? ");
|
||||
gets(TempStr); /* Throw away CR */
|
||||
sscanf(TempStr, "%d", &oldnbytes);
|
||||
for (i = 0; i < oldnbytes; i++) {
|
||||
OldRRData[i] = (char) i;
|
||||
}
|
||||
n = res_mkquery(UPDATEM, cp, C_IN, Type,
|
||||
OldRRData, oldnbytes,
|
||||
&NewRR, packet,
|
||||
sizeof(packet));
|
||||
} else { /* Modify all */
|
||||
n = res_mkquery(UPDATEMA, cp,
|
||||
C_IN, Type, NULL, 0,
|
||||
&NewRR, packet,
|
||||
sizeof(packet));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef ALLOW_T_UNSPEC
|
||||
case 'D':
|
||||
n = res_mkquery(UPDATEDA, cp, C_IN, T_UNSPEC, (char *)0,
|
||||
0, NULL, packet, sizeof(packet));
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
{
|
||||
char TempStr[100];
|
||||
int nbytes, i;
|
||||
printf("How many data bytes in oldrr data? ");
|
||||
gets(TempStr); /* Throw away CR */
|
||||
sscanf(TempStr, "%d", &nbytes);
|
||||
for (i = 0; i < nbytes; i++) {
|
||||
OldRRData[i] = (char) i;
|
||||
}
|
||||
n = res_mkquery(UPDATED, cp, C_IN, T_UNSPEC,
|
||||
OldRRData, nbytes, NULL, packet,
|
||||
sizeof(packet));
|
||||
}
|
||||
break;
|
||||
#endif ALLOW_T_UNSPEC
|
||||
#endif ALLOW_UPDATES
|
||||
|
||||
default:
|
||||
printf("a{host} - query T_A\n");
|
||||
printf("A{addr} - iquery T_A\n");
|
||||
printf("b{user} - query T_MB\n");
|
||||
printf("B{user} - query T_MG\n");
|
||||
printf("f{host} - query T_UINFO\n");
|
||||
printf("g{host} - query T_GID\n");
|
||||
printf("G{gid} - iquery T_GID\n");
|
||||
printf("h{host} - query T_HINFO\n");
|
||||
printf("i{host} - query T_MINFO\n");
|
||||
printf("p{host} - query T_PTR\n");
|
||||
printf("m{host} - query T_MX\n");
|
||||
printf("M{host} - query T_MAILB\n");
|
||||
printf("n{host} - query T_NS\n");
|
||||
printf("r{host} - query T_MR\n");
|
||||
printf("s{host} - query T_SOA\n");
|
||||
printf("T{host} - query T_TXT\n");
|
||||
printf("u{host} - query T_UID\n");
|
||||
printf("U{uid} - iquery T_UID\n");
|
||||
printf("x{host} - query T_AXFR\n");
|
||||
printf("w{host} - query T_WKS\n");
|
||||
printf("c{host} - query T_CNAME\n");
|
||||
printf("*{host} - query T_ANY\n");
|
||||
#ifdef ALLOW_UPDATES
|
||||
printf("^{host} - add/mod/moda (T_A/T_UNSPEC)\n");
|
||||
#ifdef ALLOW_T_UNSPEC
|
||||
printf("D{host} - deletea T_UNSPEC\n");
|
||||
printf("d{host} - delete T_UNSPEC\n");
|
||||
#endif ALLOW_T_UNSPEC
|
||||
#endif ALLOW_UPDATES
|
||||
continue;
|
||||
}
|
||||
if (n < 0) {
|
||||
printf("res_mkquery: buffer too small\n");
|
||||
continue;
|
||||
}
|
||||
if (log) {
|
||||
fprintf(log,"SEND QUERY\n");
|
||||
fp_query(packet, log);
|
||||
}
|
||||
n = res_send(packet, n, answer, sizeof(answer));
|
||||
if (n < 0) {
|
||||
printf("res_send: send error\n");
|
||||
if (log) fprintf(log, "res_send: send error\n");
|
||||
}
|
||||
else {
|
||||
if (dump_packet) {
|
||||
int f;
|
||||
f = creat("ns_packet.dump", 0644);
|
||||
write(f, answer, n);
|
||||
(void) close(f);
|
||||
}
|
||||
if (log) {
|
||||
fprintf(log, "GOT ANSWER\n");
|
||||
fp_query(answer, log);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [-v] [-i] [-r] [-d] [-p port] hostaddr\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
# from: @(#)Makefile 5.1 (Berkeley) 5/28/90
|
||||
# $Id: Makefile,v 1.4 1994/12/22 12:42:30 cgd Exp $
|
||||
|
||||
PROG= named-xfer
|
||||
SRCS= named-xfer.c db_glue.c
|
||||
CFLAGS+=-I${.CURDIR}/..
|
||||
.PATH: ${.CURDIR}/..
|
||||
BINDIR= /usr/libexec
|
||||
MAN= named-xfer.8
|
||||
|
||||
.include "../../Makefile.inc"
|
||||
.include <bsd.prog.mk>
|
|
@ -1,148 +0,0 @@
|
|||
.\" ++Copyright++ 1985
|
||||
.\" -
|
||||
.\" Copyright (c) 1985
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 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.
|
||||
.\" -
|
||||
.\" --Copyright--
|
||||
.\"
|
||||
.\" from: named.8 6.6 (Berkeley) 2/14/89
|
||||
.\" $NetBSD: named-xfer.8,v 1.2 1994/11/29 23:56:29 glass Exp $
|
||||
.\"
|
||||
.TH NAMED-XFER 8 "June 26, 1993"
|
||||
.UC 4
|
||||
.SH NAME
|
||||
named-xfer \- ancillary agent for inbound zone transfers
|
||||
.SH SYNOPSIS
|
||||
.B named-xfer
|
||||
.B \-z
|
||||
.I zone_to_transfer
|
||||
.B \-f
|
||||
.I db_file
|
||||
.B \-s
|
||||
.I serial_no
|
||||
[
|
||||
.B \-d
|
||||
.I debuglevel
|
||||
] [
|
||||
.B \-l
|
||||
.I debug_log_file
|
||||
] [
|
||||
.B \-t
|
||||
.I trace_file
|
||||
] [
|
||||
.B \-p
|
||||
.I port#
|
||||
] [
|
||||
.B \-S
|
||||
]
|
||||
.I nameserver
|
||||
...
|
||||
.SH DESCRIPTION
|
||||
.I Named-xfer
|
||||
is an ancillary program executed by
|
||||
.IR named (8)
|
||||
to perform an inbound zone transfer. It is rarely executed directly, and
|
||||
only by system administrators who are trying to debug a zone transfer problem.
|
||||
See RFC's 1033, 1034, and 1035 for more information on the Internet
|
||||
name-domain system.
|
||||
.PP
|
||||
Options are:
|
||||
.TP
|
||||
.B \-z
|
||||
specifies the name of the zone to be transferred.
|
||||
.TP
|
||||
.B \-f
|
||||
specifies the name of the file into which the zone should be dumped
|
||||
when it is received from the primary server.
|
||||
.TP
|
||||
.B \-s
|
||||
specifies the serial number of our current copy of this zone. If the
|
||||
\s-1SOA RR\s+1 we get from the primary server does not have a serial
|
||||
number higher than this, the transfer will be aborted.
|
||||
.TP
|
||||
.B \-d
|
||||
Print debugging information.
|
||||
A number after the ``d'' determines the level of
|
||||
messages printed.
|
||||
.TP
|
||||
.B \-l
|
||||
Specifies a log file for debugging messages. The default is system-
|
||||
dependent but is usually in
|
||||
.I /var/tmp
|
||||
or
|
||||
.IR /usr/tmp .
|
||||
Note that this only applies if
|
||||
.I \-d
|
||||
is also specified.
|
||||
.TP
|
||||
.B \-t
|
||||
Specifies a trace file which will contain a protocol trace of the zone
|
||||
transfer. This is probably only of interest to people debugging the name
|
||||
server itself.
|
||||
.TP
|
||||
.B \-p
|
||||
Use a different port number. The default is the standard port number
|
||||
as returned by getservbyname(3) for service ``domain''.
|
||||
.TP
|
||||
.B \-S
|
||||
Perform a restricted transfer of only the SOA, NS records and glue A
|
||||
records for the zone. The SOA record will not be loaded by named but
|
||||
will be used to determine when to verify the NS records.
|
||||
the ``stubs'' directive in
|
||||
.IR named (8)
|
||||
for more information.
|
||||
.PP
|
||||
Additional arguments are taken as name server addresses in so-called
|
||||
``dotted-quad'' syntax only; no host name are allowed here. At least
|
||||
one address must be specified. Any additional addresses will be tried
|
||||
in order if the first one fails to transfer to us successfully.
|
||||
.SH "SEE ALSO"
|
||||
named(8), resolver(3), resolver(5), hostname(7),
|
||||
RFC 882, RFC 883, RFC 973, RFC 974, RFC 1033, RFC 1034, RFC 1035, RFC 1123,
|
||||
\fIName Server Operations Guide for \s-1BIND\s+1\fR
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue