home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / N / TCPIP / NNTP-1.000 / NNTP-1 / nntp.1.5.11t / server / access_dnet.c next >
Encoding:
C/C++ Source or Header  |  1993-10-17  |  1.3 KB  |  61 lines

  1. #include "common.h"
  2. #include <sys/socket.h>
  3. #ifdef DECNET
  4.  
  5. #ifndef lint
  6. static    char    *sccsid = "@(#)access_dnet.c    1.6    (Berkeley) 1/9/88";
  7. #endif
  8.  
  9.  
  10. /*
  11.  * dnet_netnames -- return the network, subnet, and host names of
  12.  * our peer process for the DECnet domain.  Since DECnet doesn't
  13.  * have subnets, we always return "subnet_name"'s first char as '\0';
  14.  *
  15.  *    Parameters:    "sock" is the socket connect to our peer.
  16.  *            "sap" is a pointer to the result of
  17.  *            a getpeername() call.
  18.  *            "net_name", "subnet_name", and "host_name"
  19.  *            are filled in by this routine with the
  20.  *            corresponding ASCII names of our peer.
  21.  *    Returns:    Nothing.
  22.  *    Side effects:    None.
  23.  */
  24.  
  25. dnet_netnames(sock, sap, net_name, subnet_name, host_name)
  26.     int        sock;
  27.     struct sockaddr    *sap;
  28.     char        *net_name;
  29.     char        *subnet_name;
  30.     char        *host_name;
  31. {
  32.     char        *cp;
  33.     struct linger    l;
  34.     char        *getenv();
  35.  
  36.     cp = getenv("NETWORK");
  37.     (void) strcpy(net_name, cp ? cp : "DECnet");
  38.  
  39.     cp = getenv("REMNODE");
  40.     (void) strcpy(host_name, cp ? cp : "unknown");
  41.  
  42.     *subnet_name = '\0';
  43.  
  44.     /*
  45.      * Give decnet a chance to flush its buffers before the
  46.       * link is killed.
  47.      */
  48.  
  49.     l.l_onoff = 1;        /* on */
  50.     l.l_linger = 15;    /* seconds */
  51.  
  52.     if (setsockopt(sock, SOL_SOCKET, SO_LINGER, (char *) &l,
  53.         sizeof (l)) < 0) {
  54. #ifdef LOG
  55.         syslog(LOG_ERR,
  56.             "access_dnet: setsockopt SOL_SOCKET SO_LINGER: %m");
  57. #endif
  58.     }
  59. }
  60. #endif
  61.