Diff for /src/usr.sbin/ypserv/yp_dnslookup.c between versions 1.2 and 1.3

version 1.2, 2003/06/17 04:30:04 version 1.3, 2004/03/31 23:20:22
Line 30 Line 30
  * SUCH DAMAGE.   * SUCH DAMAGE.
  *   *
  * $FreeBSD: src/usr.sbin/ypserv/yp_dnslookup.c,v 1.16.2.1 2002/02/15 00:47:00 des Exp $   * $FreeBSD: src/usr.sbin/ypserv/yp_dnslookup.c,v 1.16.2.1 2002/02/15 00:47:00 des Exp $
 * $DragonFly: src/usr.sbin/ypserv/yp_dnslookup.c,v 1.1 2003/06/16 07:40:04 dillon Exp $ * $DragonFly$
  */   */
   
 /*  /*
Line 64 Line 64
 #include <rpcsvc/yp.h>  #include <rpcsvc/yp.h>
 #include "yp_extern.h"  #include "yp_extern.h"
   
static char *parse(hp)static char *
        struct hostent *hp;parse(struct hostent *hp)
 {  {
         static char result[MAXHOSTNAMELEN * 2];          static char result[MAXHOSTNAMELEN * 2];
         int len,i;          int len,i;
Line 122  struct circleq_dnsentry { Line 122  struct circleq_dnsentry {
   
 static int pending = 0;  static int pending = 0;
   
int yp_init_resolver()int
 yp_init_resolver(void)
 {  {
         CIRCLEQ_INIT(&qhead);          CIRCLEQ_INIT(&qhead);
         if (!(_res.options & RES_INIT) && res_init() == -1) {          if (!(_res.options & RES_INIT) && res_init() == -1) {
Line 140  int yp_init_resolver() Line 141  int yp_init_resolver()
         return(0);          return(0);
 }  }
   
static struct circleq_dnsentry *yp_malloc_dnsent()static struct circleq_dnsentry *
 yp_malloc_dnsent(void)
 {  {
        register struct circleq_dnsentry *q;        struct circleq_dnsentry *q;
   
         q = (struct circleq_dnsentry *)malloc(sizeof(struct circleq_dnsentry));          q = (struct circleq_dnsentry *)malloc(sizeof(struct circleq_dnsentry));
   
Line 157  static struct circleq_dnsentry *yp_mallo Line 159  static struct circleq_dnsentry *yp_mallo
 /*  /*
  * Transmit a query.   * Transmit a query.
  */   */
static unsigned long yp_send_dns_query(name, type)static unsigned long
        char *name;yp_send_dns_query(char *name, int type)
        int type; 
 {  {
         char buf[MAXPACKET];          char buf[MAXPACKET];
         int n;          int n;
Line 193  static unsigned long yp_send_dns_query(n Line 194  static unsigned long yp_send_dns_query(n
         return(id);          return(id);
 }  }
   
static struct circleq_dnsentry *yp_find_dnsqent(id, type)static struct circleq_dnsentry *
        unsigned long id;yp_find_dnsqent(unsigned long id, int type)
        int type; 
 {  {
        register struct circleq_dnsentry *q;        struct circleq_dnsentry *q;
   
         for (q = qhead.cqh_first; q != (void *)&qhead; q = q->links.cqe_next) {          for (q = qhead.cqh_first; q != (void *)&qhead; q = q->links.cqe_next) {
                 switch (type) {                  switch (type) {
Line 215  static struct circleq_dnsentry *yp_find_ Line 215  static struct circleq_dnsentry *yp_find_
         return (NULL);          return (NULL);
 }  }
   
static void yp_send_dns_reply(q, buf)static void
        struct circleq_dnsentry *q;yp_send_dns_reply(struct circleq_dnsentry *q, char *buf)
        char *buf; 
 {  {
         ypresponse result_v1;          ypresponse result_v1;
         ypresp_val result_v2;          ypresp_val result_v2;
Line 312  static void yp_send_dns_reply(q, buf) Line 311  static void yp_send_dns_reply(q, buf)
  * Decrement TTL on all queue entries, possibly nuking   * Decrement TTL on all queue entries, possibly nuking
  * any that have been around too long without being serviced.   * any that have been around too long without being serviced.
  */   */
void yp_prune_dnsq()void
 yp_prune_dnsq(void)
 {  {
        register struct circleq_dnsentry *q, *n;        struct circleq_dnsentry *q, *n;
   
         q = qhead.cqh_first;          q = qhead.cqh_first;
         while (q != (void *)&qhead) {          while (q != (void *)&qhead) {
Line 339  void yp_prune_dnsq() Line 339  void yp_prune_dnsq()
  * Data is pending on the DNS socket; check for valid replies   * Data is pending on the DNS socket; check for valid replies
  * to our queries and dispatch them to waiting clients.   * to our queries and dispatch them to waiting clients.
  */   */
void yp_run_dnsq()void
 yp_run_dnsq(void)
 {  {
        register struct circleq_dnsentry *q;        struct circleq_dnsentry *q;
         char buf[sizeof(HEADER) + MAXPACKET];          char buf[sizeof(HEADER) + MAXPACKET];
         char retrybuf[MAXHOSTNAMELEN];          char retrybuf[MAXHOSTNAMELEN];
         struct sockaddr_in sin;          struct sockaddr_in sin;
Line 423  void yp_run_dnsq() Line 424  void yp_run_dnsq()
 /*  /*
  * Queue and transmit an asynchronous DNS hostname lookup.   * Queue and transmit an asynchronous DNS hostname lookup.
  */   */
ypstat yp_async_lookup_name(rqstp, name)ypstat
        struct svc_req *rqstp;yp_async_lookup_name(struct svc_req *rqstp, char *name)
        char *name; 
 {  {
        register struct circleq_dnsentry *q;        struct circleq_dnsentry *q;
         int type, len;          int type, len;
   
         /* Check for SOCK_DGRAM or SOCK_STREAM -- we need to know later */          /* Check for SOCK_DGRAM or SOCK_STREAM -- we need to know later */
Line 477  ypstat yp_async_lookup_name(rqstp, name) Line 477  ypstat yp_async_lookup_name(rqstp, name)
 /*  /*
  * Queue and transmit an asynchronous DNS IP address lookup.   * Queue and transmit an asynchronous DNS IP address lookup.
  */   */
ypstat yp_async_lookup_addr(rqstp, addr)ypstat yp_async_lookup_addr(struct svc_req *rqstp, char *addr)
        struct svc_req *rqstp; 
        char *addr; 
 {  {
        register struct circleq_dnsentry *q;        struct circleq_dnsentry *q;
         char buf[MAXHOSTNAMELEN];          char buf[MAXHOSTNAMELEN];
         int a, b, c, d;          int a, b, c, d;
         int type, len;          int type, len;

Removed from v.1.2  
changed lines
  Added in v.1.3