9788050
diff --git a/src/autoconf b/src/autoconf
9788050
index 3a52e6c..ff78048 100755
9788050
--- a/src/autoconf
9788050
+++ b/src/autoconf
53e398d
@@ -68,8 +68,6 @@
53e398d
 #	#define NOfsync
53e398d
 #Ok	#define endpwent()
53e398d
 #Ok	#define endgrent()
53e398d
-#Ok	#define endhostent()
53e398d
-#Ok	#define endservent()
53e398d
 #Ok	#define endprotoent()
53e398d
 #	#define h_0addr_list h_addr
53e398d
 #Ok	#define NOpw_passwd
9788050
@@ -896,7 +894,7 @@ int main(){int i=0;
53e398d
  {uid_t vuid_t;i+=vuid_t=1;}
53e398d
  {gid_t vgid_t;i+=vgid_t=1;}
53e398d
 #ifndef NO_COMSAT
53e398d
- {struct hostent vhostent;i+=!(vhostent.h_addr_list=0);}
53e398d
+ {struct addrinfo res; i+=!(res.ai_socktype=0);}
53e398d
 #endif
53e398d
 #ifndef NOuname
53e398d
  {struct utsname vutsname;i+=!(*vutsname.nodename='\0');}
9788050
@@ -917,8 +915,6 @@ do
53e398d
   test -z "$i3" && grepfor mode_t 'typedef int mode_t;' && i3=I
53e398d
   test -z "$i4" && grepfor uid_t 'typedef int uid_t;' && i4=I
53e398d
   test -z "$i5" && grepfor gid_t 'typedef int gid_t;' && i5=I
53e398d
-  test -z "$i6" && grepfor h_addr_list '#define h_0addr_list h_addr' && i6=I
53e398d
-  test -z "$i6" && grepfor hostent '#define h_0addr_list h_addr' && i6=I
53e398d
   test -z "$i6" && grepfor member '#define h_0addr_list h_addr' && i6=I
53e398d
   test -z "$i7" && grepfor utsname "#define NOuname			      \
53e398d
 /* <sys/utsname.h> is there, but empty */" && i7=I
9788050
@@ -1048,8 +1044,12 @@ int main(){char a[2];
53e398d
  {struct utsname b;uname(&b);}
53e398d
 #endif
53e398d
 #ifndef NO_COMSAT
53e398d
- gethostbyname("0");getprotobyname(COMSATprotocol);endhostent();endservent();
53e398d
- endprotoent();
53e398d
+ {
53e398d
+ struct addrinfo *res, hints;
53e398d
+ memset(&hints, '\0', sizeof(hints));
53e398d
+ if(getaddrinfo(COMSAThost,BIFF_serviceport,&hints,&res))
53e398d
+ 	freeaddrinfo(res);
53e398d
+ }
53e398d
 #endif
53e398d
  _exit(0);
53e398d
  return 0;}
9788050
@@ -1103,14 +1103,9 @@ grepfor uname "\
53e398d
 /* <sys/utsname.h> defines it, the libraries don't */"
53e398d
 grepfor endpwent '#define endpwent()'
53e398d
 grepfor endgrent '#define endgrent()'
53e398d
-if grepfor gethostbyname '#define NO_COMSAT'
53e398d
+if grepfor getaddrinfo '#define NO_COMSAT'
53e398d
 then
53e398d
 :
53e398d
-else
53e398d
-  grepfor getprotobyname '#define UDP_protocolno 17'
53e398d
-  grepfor endhostent '#define endhostent()'
53e398d
-  grepfor endservent '#define endservent()'
53e398d
-  grepfor endprotoent '#define endprotoent()'
53e398d
 fi
53e398d
 grepfor strstr '#define SLOWstrstr' ||
53e398d
  grepfor clock '#define SLOWstrstr'
9788050
@@ -1239,39 +1234,9 @@ int main(argc,argv)int argc;const char*argv[];
53e398d
 	printf("/* Insufficient memory to perform the benchmark! */\n");
53e398d
 #endif /* SLOWstrstr */
53e398d
 #ifndef NO_COMSAT
53e398d
-#ifndef UDP_protocolno
53e398d
-     ;{ const struct protoent*p;
53e398d
-	if(p=getprotobyname(COMSATprotocol))
53e398d
-	 { printf("#define UDP_protocolno %d\n",p->p_proto);
53e398d
-#else
53e398d
-     ;{ if(1)
53e398d
-	 {
53e398d
-#endif
53e398d
-	   ;{ const struct servent*serv;
53e398d
-	      if(serv=getservbyname(COMSATservice,COMSATprotocol))
53e398d
-		 printf("#define BIFF_serviceport \"%d\"\n",
53e398d
-		  ntohs(serv->s_port));
53e398d
-	    }
53e398d
-#ifdef AF_INET
53e398d
-	   ;{ const struct hostent*host;
53e398d
-	      if(!strcmp("localhost",COMSAThost)&&
53e398d
-	       (host=gethostbyname(COMSAThost))&&
53e398d
-	       host->h_0addr_list&&host->h_addrtype==AF_INET&&
53e398d
-	       host->h_length)
53e398d
-	       { int j=host->h_length;
53e398d
-		 const unsigned char*ad=(void*)host->h_0addr_list;
53e398d
-		 printf("#define IP_localhost {");
53e398d
-		 printf("%d",*ad++);
53e398d
-		 while(--j)
53e398d
-		    printf(",%d",*ad++);
53e398d
-		 puts("}");
53e398d
-	       }
53e398d
-	    }
53e398d
+#ifndef AF_INET
53e398d
+	puts("#define NO_COMSAT");
53e398d
 #endif /* AF_INET */
53e398d
-	 }
53e398d
-	else
53e398d
-	   puts("#define NO_COMSAT");
53e398d
-      }
53e398d
 #endif /* NO_COMSAT */
53e398d
      ;{ unsigned long s=(size_t)~0;int bits;
53e398d
 	for(bits=1;s>>=1;bits++);
9788050
diff --git a/src/comsat.c b/src/comsat.c
9788050
index 9712e74..5082b16 100644
9788050
--- a/src/comsat.c
9788050
+++ b/src/comsat.c
9788050
@@ -27,7 +27,8 @@ static /*const*/char rcsid[]=
53e398d
 #include "comsat.h"
53e398d
 
53e398d
 static int csvalid;		     /* is it turned on with a good address? */
53e398d
-static struct sockaddr_in csaddr;
53e398d
+static struct addrinfo cai;
53e398d
+static struct sockaddr *csaddr;
53e398d
 static char*cslastf,*cslgname;
53e398d
 
53e398d
 void setlfcs(folder)const char*folder;		/* set lastfolder for comsat */
9788050
@@ -62,56 +63,32 @@ void setlgcs(name)const char*name;		   /* set logname for comsat */
53e398d
 }
53e398d
 
53e398d
 int setcomsat(chp)const char*chp;
53e398d
-{ char*chad;int newvalid; struct sockaddr_in newaddr;
53e398d
+{ char*chad;int newvalid; struct addrinfo *res, hints;
53e398d
   chad=strchr(chp,SERV_ADDRsep);			     /* @ separator? */
53e398d
   if(!chad&&!renvint(-1L,chp))
53e398d
      return csvalid=0;					/* turned off comsat */
53e398d
   newvalid=1;
53e398d
   if(chad)
53e398d
      *chad++='\0';				      /* split the specifier */
53e398d
+  if(!chad||!*chp)					       /* no service */
53e398d
+     chp=BIFF_serviceport;				/* new balls please! */
53e398d
   if(!chad||!*chad)						  /* no host */
53e398d
-#ifndef IP_localhost			      /* Is "localhost" preresolved? */
53e398d
      chad=COMSAThost;					/* nope, use default */
53e398d
-#else /* IP_localhost */
53e398d
-   { static const unsigned char ip_localhost[]=IP_localhost;
53e398d
-     newaddr.sin_family=AF_INET;
53e398d
-     tmemmove(&newaddr.sin_addr,ip_localhost,sizeof ip_localhost);
53e398d
-   }
53e398d
-  else
53e398d
-#endif /* IP_localhost */
53e398d
-   { const struct hostent*host;		      /* what host?  paranoid checks */
53e398d
-     if(!(host=gethostbyname(chad))||!host->h_0addr_list)
53e398d
-      { bbzero(&newaddr.sin_addr,sizeof newaddr.sin_addr);
53e398d
-	newvalid=0;			     /* host can't be found, too bad */
53e398d
-      }
53e398d
-     else
53e398d
-      { newaddr.sin_family=host->h_addrtype;	     /* address number found */
53e398d
-	tmemmove(&newaddr.sin_addr,host->h_0addr_list,host->h_length);
53e398d
-      }
53e398d
-     endhostent();
53e398d
-   }
53e398d
-  if(newvalid)						  /* so far, so good */
53e398d
-   { int s;
53e398d
-     if(!chad||!*chp)					       /* no service */
53e398d
-	chp=BIFF_serviceport;				/* new balls please! */
53e398d
-     s=strtol(chp,&chad,10);
53e398d
-     if(chp!=chad)			       /* the service is not numeric */
53e398d
-	newaddr.sin_port=htons((short)s);		    /* network order */
53e398d
-     else
53e398d
-      { const struct servent*serv;
53e398d
-	serv=getservbyname(chp,COMSATprotocol);		   /* so get its no. */
53e398d
-	if(serv)
53e398d
-	   newaddr.sin_port=serv->s_port;
53e398d
-	else
53e398d
-	 { newaddr.sin_port=htons((short)0);		  /* no such service */
53e398d
-	   newvalid=0;
53e398d
-	 }
53e398d
-	endservent();
53e398d
-      }
53e398d
-   }
53e398d
+  bzero(&hints,sizeof(hints));
53e398d
+  hints.ai_socktype=SOCK_DGRAM;
53e398d
+  hints.ai_flags=AI_ADDRCONFIG;
53e398d
+  if(getaddrinfo(chad,chp,&hints,&res))
53e398d
+     newvalid=0;
53e398d
+  
53e398d
   onguard();				    /* update the address atomically */
53e398d
   if(csvalid=newvalid)
53e398d
-     tmemmove(&csaddr,&newaddr,sizeof(newaddr));
53e398d
+   { if(csaddr)
53e398d
+        free(csaddr);
53e398d
+     csaddr=malloc(res->ai_addrlen);
53e398d
+     tmemmove(csaddr,res->ai_addr,res->ai_addrlen);
53e398d
+     tmemmove(&cai,res,sizeof(cai));
53e398d
+     freeaddrinfo(res);
53e398d
+   }
53e398d
   offguard();
53e398d
   return newvalid;
53e398d
 }
9788050
@@ -132,8 +109,8 @@ void sendcomsat(folder)const char*folder;
53e398d
    }
53e398d
   strlcat(buf,COMSATxtrsep,linebuf);			 /* custom seperator */
53e398d
   strlcat(buf,p,linebuf);			  /* where was it delivered? */
53e398d
-  if((s=socket(AF_INET,SOCK_DGRAM,UDP_protocolno))>=0)
53e398d
-   { sendto(s,buf,strlen(buf),0,(struct sockaddr*)&csaddr,sizeof(csaddr));
53e398d
+  if((s=socket(cai.ai_family,cai.ai_socktype,cai.ai_protocol))>=0)
53e398d
+   { sendto(s,buf,strlen(buf),0,csaddr,cai.ai_addrlen);
53e398d
      rclose(s);
53e398d
      yell("Notified comsat:",buf);
53e398d
    }
9788050
diff --git a/src/network.h b/src/network.h
9788050
index d7d08f2..b09b6c4 100644
9788050
--- a/src/network.h
9788050
+++ b/src/network.h
9788050
@@ -1,19 +1,13 @@
9788050
 /*$Id: network.h,v 1.7 1997/04/02 03:15:41 srb Exp $*/
9788050
 
9788050
-#include <sys/socket.h>			/* socket() sendto() AF_INET
9788050
+#include <sys/socket.h>			/* socket() sendto() */
9788050
 					/* SOCK_DGRAM */
9788050
-#include <netdb.h>			/* gethostbyname() getservbyname()
9788050
-					/* getprotobyname() */
9788050
-#include <netinet/in.h>			/* htons() struct sockaddr_in */
9788050
+#include <netdb.h>			/* getaddrinfo() */
9788050
 
9788050
 #ifndef BIFF_serviceport
9788050
 #define BIFF_serviceport	COMSATservice
9788050
 #endif
9788050
 
9788050
-#ifndef h_0addr_list
9788050
-#define h_0addr_list	h_addr_list[0]		      /* POSIX struct member */
9788050
-#endif
9788050
-
9788050
 #ifndef NO_const      /* since network.h is outside the autoconf const check */
9788050
 #ifdef const		    /* loop, we need this backcheck for some systems */
9788050
 #undef const