home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / nntp1.5 / part01 / server / access_dnet.c next >
Encoding:
C/C++ Source or Header  |  1988-04-18  |  1.4 KB  |  65 lines

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