home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / TCPIP / NETKIT-A.06 / NETKIT-A / NetKit-A-0.06 / tcp_wrapper-6.3 / fromhost.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-27  |  2.5 KB  |  84 lines

  1.  /*
  2.   * On socket-only systems, fromhost() is nothing but an alias for the
  3.   * socket-specific sock_host() function.
  4.   * 
  5.   * On systems with sockets and TLI, fromhost() determines the type of API
  6.   * (sockets, TLI), then invokes the appropriate API-specific routines.
  7.   * 
  8.   * The API-specific routines determine the nature of the service (datagram,
  9.   * stream), and the name and address of the host at the other end. In case
  10.   * of an IP service, these routines also determine the local address and
  11.   * port, and the remote username if username lookups are done irrespective
  12.   * of client. All results are in static memory.
  13.   * 
  14.   * The return value is (-1) if the remote host pretends to have someone elses
  15.   * name, or if the remote host name is available but could not be verified;
  16.   * in either case the hostname will be ignored. The return status is zero in
  17.   * all other cases (the hostname is unavailable, or the host name double
  18.   * check succeeds).
  19.   * 
  20.   * Diagnostics are reported through syslog(3).
  21.   * 
  22.   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
  23.   */
  24.  
  25. #ifndef lint
  26. static char sccsid[] = "@(#) fromhost.c 1.16 94/03/23 16:23:45";
  27. #endif
  28.  
  29. /* System libraries. */
  30.  
  31. #include <sys/types.h>
  32. #include <stdio.h>
  33. #include <syslog.h>
  34.  
  35. #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
  36. #include <sys/tiuser.h>
  37. #include <stropts.h>
  38. #endif
  39.  
  40. /* Local stuff. */
  41.  
  42. #include "log_tcp.h"
  43.  
  44. #if !defined(TLI) && !defined(PTX) && !defined(TLI_SEQUENT)
  45.  
  46. /* fromhost - compatibility wrapper for socket-only systems */
  47.  
  48. int     fromhost(client)
  49. struct client_info *client;
  50. {
  51.     int     client_fd = 0;        /* XXX compatibility */
  52.  
  53.     return (sock_host(client, client_fd));
  54. }
  55.  
  56. #endif /* !TLI && !PTX && !TLI_SEQUENT */
  57.  
  58. #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
  59.  
  60. /* fromhost - find out what network API we should use */
  61.  
  62. int     fromhost(client)
  63. struct client_info *client;
  64. {
  65.     int     client_fd = 0;        /* XXX compatibility */
  66.  
  67.     /*
  68.      * On systems with streams support the IP network protocol family may
  69.      * have more than one programming interface (sockets and TLI).
  70.      * 
  71.      * Thus, we must first find out what programming interface to use: sockets
  72.      * or TLI. On some systems, sockets are not part of the streams system,
  73.      * so if stdin is not a stream we assume sockets.
  74.      */
  75.  
  76.     if (ioctl(client_fd, I_FIND, "timod") > 0) {
  77.     return (tli_host(client, client_fd));
  78.     } else {
  79.     return (sock_host(client, client_fd));
  80.     }
  81. }
  82.  
  83. #endif /* TLI || PTX || TLI_SEQUENT */
  84.