/*
 *  gcc -B/usr/ccs/bin/ -fpic -c gethost_wrapper.c
 *  /usr/ccs/bin/ld -G -o /usr/local/lib/gethost_wrapper.so gethost_wrapper.o
 *
 *  This is used via LD_PRELOAD if you want to prevent a program
 *  from successfully calling gethostbyaddr, perhaps because the
 *  data obtained by gethostbyaddr would risk overflowing a buffer.
 *
 *  mhpower, 14 October 1997
 *
 */

#include <stdio.h>
#include <syslog.h>

struct  hostent {
        char    *h_name;        /* official name of host */
        char    **h_aliases;    /* alias list */
        int     h_addrtype;     /* host address type */
        int     h_length;       /* length of address */
        char    **h_addr_list;  /* list of addresses from name server */
#define h_addr  h_addr_list[0]  /* address, for backward compatiblity */
};

struct hostent *gethostbyaddr(addr, len, type)
        char *addr;
        int len, type;
{
   openlog("gethost_wrapper", LOG_PID, LOG_DAEMON);
   syslog(LOG_INFO, "intercepted gethostbyaddr of %d.%d.%d.%d",
    ((unsigned)addr[0] & 0xff), ((unsigned)addr[1] & 0xff),
    ((unsigned)addr[2] & 0xff), ((unsigned)addr[3] & 0xff));
   closelog();
   return ((struct hostent *) NULL);
}
