host.c File Reference

#include <stdio.h>
#include <sys/types.h>
#include <arpa/nameser.h>
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <resolv.h>
#include <sys/param.h>
#include <strings.h>
#include <ctype.h>

Include dependency graph for host.c:

Go to the source code of this file.

Data Structures

union  querybuf

Defines

#define NUMMX   50
#define SUCCESS   0
#define TIME_OUT   -1
#define NO_INFO   -2
#define ERROR   -3
#define NONAUTH   -4
#define NAME_LEN   256
#define T_TXT   16
#define NO_DATA   NO_ADDRESS
#define C_HS   4
#define NUMNS   8
#define IPADDRSIZE   4
#define NUMNSADDR   16

Typedefs

typedef querybuf querybuf_t

Functions

int main _ARGS ((int c, char *v[]))
static int parsetype _ARGS ((char *s))
static void hperror _ARGS ((int errno))
static void printanswer _ARGS ((struct hostent *hp))
static int ListHosts _ARGS ((char *namePtr, int queryType))
static int gethostinfo _ARGS ((char *name))
static int getdomaininfo _ARGS ((char *name, char *domain))
static int getinfo _ARGS ((char *name, char *domain, int type))
static int printinfo _ARGS ((union querybuf *answer, u8_t *eom, int filter, int isls))
static char *DecodeError _ARGS ((int result))
static u8_t *pr_rr _ARGS ((u8_t *cp, u8_t *msg, FILE *file, int filter))
static u8_t *pr_cdname _ARGS ((u8_t *cp, u8_t *msg, u8_t *name, int namelen))
static char *pr_class _ARGS ((int class))
static char *pr_type _ARGS ((int type))
static int tcpip_writeall _ARGS ((int fd, char *buf, unsigned siz))
int main (c, char **v)
static int parsetype (char *s)
static int parseclass (char *s)
static void printanswer (struct hostent *hp)
static void hperror (int errno)
static int gethostinfo (char *name)
static int getdomaininfo (char *name, char *domain)
static int getinfo (char *name, char *domain, type)
static int printinfo (querybuf_t *answer, u8_t *eom, int filter, int isls)
static u8_tpr_rr (u8_t *cp, u8_t *msg, FILE *file, int filter)
static char * pr_type (int type)
static char * pr_class (int class)
static u8_tpr_cdname (u8_t *cp, u8_t *msg, u8_t *name, int namelen)
static int ListHosts (char *namePtr, int queryType)
static char * DecodeError (int result)
static int tcpip_writeall (int fd, char *buf, unsigned siz)

Variables

int h_errno
FILEfilePtr
state orig
state _res
static u8_tcname = NULL
int getclass = C_IN
int gettype
int getdeftype = T_A
int verbose = 0
int list = 0
int server_specified = 0
static u8_t hostbuf [BUFSIZ+1]
static u8_t cnamebuf [MAXDNAME]
static char nbuf [20]
char * resultcodes []


Define Documentation

#define C_HS   4
 

Definition at line 74 of file host.c.

Referenced by parseclass(), and pr_class().

#define ERROR   -3
 

Definition at line 62 of file host.c.

#define IPADDRSIZE   4
 

Referenced by ListHosts().

#define NAME_LEN   256
 

Definition at line 65 of file host.c.

Referenced by ListHosts().

#define NO_DATA   NO_ADDRESS
 

Definition at line 71 of file host.c.

Referenced by printinfo(), and res_query().

#define NO_INFO   -2
 

Definition at line 61 of file host.c.

Referenced by DecodeError().

#define NONAUTH   -4
 

Definition at line 63 of file host.c.

Referenced by DecodeError().

#define NUMMX   50
 

Definition at line 57 of file host.c.

#define NUMNS   8
 

Referenced by ListHosts().

#define NUMNSADDR   16
 

Referenced by ListHosts().

#define SUCCESS   0
 

Definition at line 59 of file host.c.

#define T_TXT   16
 

Definition at line 68 of file host.c.

Referenced by parsetype(), pr_rr(), pr_type(), and query_chaos().

#define TIME_OUT   -1
 

Definition at line 60 of file host.c.

Referenced by DecodeError().


Typedef Documentation

typedef union querybuf querybuf_t
 


Function Documentation

static int tcpip_writeall _ARGS (int fd, char *buf, unsigned siz)   )  [static]
 

static char* pr_type _ARGS (int type  )  [static]
 

static char* pr_class _ARGS (int class)   )  [static]
 

static u8_t* pr_cdname _ARGS (u8_t *cp, u8_t *msg, u8_t *name, int namelen)   )  [static]
 

static u8_t* pr_rr _ARGS (u8_t *cp, u8_t *msg, FILE *file, int filter)   )  [static]
 

static char* DecodeError _ARGS (int result  )  [static]
 

static int printinfo _ARGS (union querybuf *answer, u8_t *eom, int filter, int isls)   )  [static]
 

static int getinfo _ARGS (char *name, char *domain, int type  )  [static]
 

static int getdomaininfo _ARGS (char *name, char *domain)   )  [static]
 

static int gethostinfo _ARGS (char *name  )  [static]
 

static int ListHosts _ARGS (char *namePtr, int queryType)   )  [static]
 

static void printanswer _ARGS (struct hostent *hp)   )  [static]
 

static void hperror _ARGS (int errno  )  [static]
 

static int parseclass _ARGS (char *s  )  [static]
 

int main _ARGS (int c, char *v[])   ) 
 

static char* DecodeError int  result  )  [static]
 

Definition at line 1369 of file host.c.

References ERROR, FORMERR, NO_INFO, NOCHANGE, NOERROR, NONAUTH, NOTIMP, NXDOMAIN, REFUSED, SERVFAIL, and TIME_OUT.

Referenced by ListHosts(), and printinfo().

static int getdomaininfo char *  name,
char *  domain
[static]
 

Definition at line 442 of file host.c.

References getdeftype, getinfo(), and gettype.

Referenced by gethostinfo().

static int gethostinfo char *  name  )  [static]
 

Definition at line 385 of file host.c.

References cp, getdomaininfo(), n, NULL, and strcmp.

Referenced by main().

static int getinfo char *  name,
char *  domain,
type 
[static]
 

Definition at line 449 of file host.c.

References _res, answer, bp, buf, buflen, cp, getclass, h_errno, host, i, j, MAXDNAME, n, NO_RECOVERY, NULL, state::options, printf, printinfo(), QUERY, RES_DEBUG, res_mkquery(), res_send(), sprintf(), T_ANY, TRY_AGAIN, and type.

Referenced by getdomaininfo().

static void hperror int  errno  )  [static]
 

Definition at line 356 of file host.c.

References fprintf(), HOST_NOT_FOUND, NO_ADDRESS, NO_RECOVERY, stderr, and TRY_AGAIN.

Referenced by main().

static int ListHosts char *  namePtr,
int  queryType
[static]
 

Definition at line 961 of file host.c.

References _res, answer, bcopy, buf, C_IN, cp, DecodeError(), DHF_AA, DHF_RCODE, dlen, dn_expand(), dn_skipname(), ERROR, error, FORMERR, i, IPADDRSIZE, NAME_LEN, NOERROR, NOTIMP, ntohs, NUMNS, NUMNSADDR, NXDOMAIN, state::options, printf, QFIXEDSZ, QUERY, REFUSED, RES_DEBUG, res_mkquery(), res_send(), result, server_specified, SERVFAIL, strcasecmp, strlen(), strncpy(), T_A, T_NS, type, and verbose.

Referenced by main().

int main c  ,
char **  v
 

Definition at line 110 of file host.c.

References _res, addr, atoi, c, exit(), fprintf(), getclass, getdeftype, gethostbyname, gethostinfo(), gettype, h_errno, hperror(), htons, inet_aton(), inet_ntoa(), list, ListHosts(), NAMESERVER_PORT, state::nsaddr_list, state::nsport_list, NULL, state::options, p, parseclass(), parsetype(), printanswer(), printf, RES_DEBUG, RES_DEFNAMES, res_init(), RES_RECURSE, RES_USEVC, state::retrans, state::retry, s, server_specified, sprintf(), stderr, strchr, strcmp, strncmp(), T_ANY, T_PTR, TRY_AGAIN, and verbose.

static int parseclass char *  s  )  [static]
 

Definition at line 321 of file host.c.

References atoi, C_ANY, C_CHAOS, C_HS, C_IN, exit(), fprintf(), stderr, and strcmp.

Referenced by main().

static int parsetype char *  s  )  [static]
 

Definition at line 267 of file host.c.

References atoi, exit(), fprintf(), stderr, strcmp, and T_TXT.

Referenced by main().

static u8_t* pr_cdname u8_t cp,
u8_t msg,
u8_t name,
int  namelen
[static]
 

Definition at line 905 of file host.c.

References dn_expand(), n, and NULL.

Referenced by pr_rr().

static char* pr_class int  class  )  [static]
 

Definition at line 886 of file host.c.

References C_ANY, C_CHAOS, C_HS, C_IN, EOF, NULL, sprintf(), and verbose.

Referenced by pr_rr().

static u8_t* pr_rr u8_t cp,
u8_t msg,
FILE file,
int  filter
[static]
 

Definition at line 594 of file host.c.

References bcopy, c, C_IN, dlen, dn_expand(), doprint(), file, fprintf(), getprotobynumber(), getservbyport(), gettype, htons, inet_ntoa(), int(), MAXDNAME, n, NULL, pr_cdname(), pr_class(), pr_type(), proto, strcat(), T_A, T_ANY, T_CNAME, T_GID, T_HINFO, T_MB, T_MD, T_MF, T_MG, T_MINFO, T_MR, T_MX, T_NS, T_PTR, T_SOA, T_TXT, T_UID, T_UINFO, T_WKS, type, and verbose.

Referenced by printinfo().

static char* pr_type int  type  )  [static]
 

Definition at line 823 of file host.c.

References EOF, NULL, sprintf(), T_A, T_ANY, T_AXFR, T_CNAME, T_GID, T_HINFO, T_MAILA, T_MAILB, T_MB, T_MD, T_MF, T_MG, T_MINFO, T_MR, T_MX, T_NS, T_NULL, T_PTR, T_SOA, T_TXT, T_UID, T_UINFO, T_WKS, and verbose.

Referenced by pr_rr().

static void printanswer struct hostent hp  )  [static]
 

Definition at line 339 of file host.c.

References cp, inet_ntoa(), and printf.

Referenced by main().

static int printinfo querybuf_t answer,
u8_t eom,
int  filter,
int  isls
[static]
 

Definition at line 485 of file host.c.

References _res, bp, buflen, cp, DecodeError(), dns_hdr::dh_ancount, dns_hdr::dh_arcount, dns_hdr::dh_flag1, dns_hdr::dh_flag2, dns_hdr::dh_nscount, dns_hdr::dh_qdcount, DHF_AA, DHF_RCODE, dn_skipname(), FORMERR, h_errno, HOST_NOT_FOUND, i, j, n, NO_DATA, NO_RECOVERY, NOERROR, NOTIMP, ntohs, NXDOMAIN, state::options, pr_rr(), printf, QFIXEDSZ, REFUSED, RES_DEBUG, SERVFAIL, stdout, TRY_AGAIN, and verbose.

Referenced by getinfo().

static int tcpip_writeall int  fd,
char *  buf,
unsigned  siz
[static]
 

Definition at line 1389 of file host.c.

References assert, nbytes, and write.


Variable Documentation

struct state _res
 

Definition at line 52 of file res_init.c.

Referenced by endhostent(), getanswer(), gethostbyaddr(), getinfo(), ListHosts(), main(), printinfo(), res_init(), res_mkquery(), res_query(), res_querydomain(), res_search(), res_send(), and sethostent().

u8_t* cname = NULL [static]
 

Definition at line 81 of file host.c.

u8_t cnamebuf[MAXDNAME] [static]
 

Definition at line 588 of file host.c.

FILE* filePtr
 

Definition at line 77 of file host.c.

int getclass = C_IN
 

Definition at line 82 of file host.c.

Referenced by getanswer(), getinfo(), and main().

int getdeftype = T_A
 

Definition at line 83 of file host.c.

Referenced by getdomaininfo(), and main().

int gettype
 

Definition at line 83 of file host.c.

Referenced by getdomaininfo(), main(), and pr_rr().

int h_errno
 

Definition at line 69 of file res_query.c.

Referenced by getanswer(), gethostbyname(), getinfo(), main(), printinfo(), res_init(), res_query(), and res_search().

u8_t hostbuf[BUFSIZ+1] [static]
 

Definition at line 381 of file host.c.

int list = 0
 

Definition at line 85 of file host.c.

Referenced by addtomach(), c_list(), caselist(), cleandir(), command(), delete_config(), descendtree(), dogroup(), m_paragraph(), main(), parsecmd(), push_attr(), restore_attr(), and shorten().

char nbuf[20] [static]
 

Definition at line 817 of file host.c.

Referenced by chg_buf(), do_file(), dumpopts(), main(), and res_querydomain().

struct state orig
 

Definition at line 79 of file host.c.

Referenced by main().

char* resultcodes[]
 

Initial value:

 {
        "NOERROR",
        "FORMERR",
        "SERVFAIL",
        "NXDOMAIN",
        "NOTIMP",
        "REFUSED",
        "6",
        "7",
        "8",
        "9",
        "10",
        "11",
        "12",
        "13",
        "14",
        "NOCHANGE",
}

Definition at line 921 of file host.c.

int server_specified = 0
 

Definition at line 86 of file host.c.

Referenced by ListHosts(), and main().

int verbose = 0
 

Definition at line 84 of file host.c.


Generated on Fri Apr 14 23:06:40 2006 for minix by  doxygen 1.4.6