tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SUMMARY: Obtaining LAT node/port, DU 3.2d
@ 1996-04-15  4:26 Michael A. Crowley
  0 siblings, 0 replies; only message in thread
From: Michael A. Crowley @ 1996-04-15  4:26 UTC (permalink / raw)
  To: tru64-unix-managers


In my original inquiry:
	In trying to modify the logdaemon package
	(ftp://ftp.win.tue.nl/pub/security/logdaemon-5.0.tar.Z) to
	display the LAT node/port number, I've been unable
	to figure out how to obtain those strings.

I now have answers for the original inquiry, but I am still working
on dealing with that package apparently not handling the utmp
entries correctly.  But that might be a new question someday.
----------
For code segments, I'd like to thank:
	Scott W. Ruch   <swr@unx.dec.com>, Phil Vitale, and
	Karl E. Kelley  <kekelley@iastate.edu> 
Also, <hubcap@hubcap.clemson.edu>,  pointed out /usr/examples/lat
which I had forgotten the existence of.
And finally, Matt Thomas whose general advice is always welcome.

I would also like to point out:  man 7 streamio
----------
Below is the module "checklat" that I use in the logdaemon package
and is part of a modification of the "~/login/login.c" file and
illustrates the way of getting LAT node/port numbers.  I'm 
not providing the whole thing yet because another module, 
"~/lib/utmp_login.c", is not working correctly with telnet 
or dlogin connections, a problem that preceeded my modification.  ;)
The LAT logins do work correctly since the utmp slots are already in place.

=============================================================================
checklat()
-----------------------------------------------------------------------------
/* Returns NULL if non-LAT */

#ifdef DU_ULTRIX_LAT
#if defined ultrix

/************* Conditional Ultrix section ********************************/

char *
checklat()
{
	struct ltattyi  ltainfo;
	static char     lat_hostport[MAXLTASERVSIZE + MAXLTAPORTSIZE + 2];

	lat_hostport[0] = '\0';

	if (ioctl(0, LIOCTTYI, &ltainfo) >= 0) {
		strcpy(lat_hostport, ltainfo.lta_server_name);
		strcat(lat_hostport, "/");
		strcat(lat_hostport, ltainfo.lta_server_port);
		return (lat_hostport);
	} else {
		return (0);
	}
}

#elif defined __osf__

/************* Conditional Digital UNIX section ***************************/

char *
checklat()
{
     /*** +4 for some slop; used twice here */
     static char tty[NA_MAX + NA_MAX + 4];  
     char *ptty;
     struct stat statbuf;
     lats_info lat_information;
     struct strioctl strioctl;

     /***  Is this a streams device (LAT) */
     if  (isastream(0) == 0) {     
	/* Cannot be a LAT port */
	return(0);
     }

     bzero(tty, NA_MAX + NA_MAX + 4);
     bzero(&lat_information, sizeof(lats_info));
     bzero(&statbuf, sizeof(statbuf));

     /*** Load tty with name */
     strcat(tty, ttyname(0));  

#ifdef TESTING
      printf("TEST:  tty set to <%s>\n",tty);
#endif

     if (stat(tty, &statbuf) < 0) {
#ifndef TESTING
	return(0);
#else
	return("TEST: should not get here");
#endif
     }

     /* Obtain minor device number                                       */
	/* minor and major defined in <sys/types.h>                      */
	/* major(0xXXXYYYYYY) -> 0xXXX                                   */
	/* minor(0xXXXYYYYYY) -> 0xYYYYY                                 */
	/* st_rdev is (in hex) XXXYYYYY where X is major, Y is minor dev */
        /* lat_information.info_dev:                                     */
	/* LAT stream index (from <lat/streams/latioc.h> )               */

     lat_information.info_dev = minor(statbuf.st_rdev);

     bzero(&strioctl, sizeof(struct strioctl));
     /* strioctl: from <stropts.h> */
     strioctl.ic_cmd = LIOC_INFO_SHOW;
     strioctl.ic_len = sizeof(lats_info);
     strioctl.ic_dp = (char *)&lat_information;
     if (ioctl(0, I_STR, &strioctl)  < 0) {
#ifndef TESTING
	return(0);
#else
        return("TEST: LIOC_INFO_SHOW ioctl failed, not LAT after all.");
	return(0);
#endif
     }
     /* Comes out of here if it is a LAT device */

#ifdef TESTING
     printf("\nLocal Port Name = %s", tty);
#endif

   /*  SAMPLE output from testing
   ============================================================================
    /dev/lat/821    (SYS-V)
    Node Name = CARTS2
    Port Name = PORT_11
   15:42  up 3 days,  6:32,  16 users,  load average: 0.14, 0.16, 0.13
   User     tty        from             login@    idle   JCPU   PCPU what
   mcrowley lat/821    CARTS2/PORT_11   15:41                        w mcrowley
   ============================================================================
    /dev/tty26      (BSD)
    Node Name = CARTS2
    Port Name = PORT_11
   15:43  up 53 days, 15:40,  86 users,  load average: 2.76, 2.20, 1.89
   User     tty        from             login@    idle   JCPU   PCPU what
   mcrowley 26         CARTS2/PORT_11   15:42                        w mcrowley
   ============================================================================
   */
     bzero(tty, NA_MAX + NA_MAX + 4);
     if (lat_information.rmt_node[0] != NULL) {
     	  strcpy(tty,lat_information.rmt_node);
#ifdef TESTING
          printf("\tNode Name = %s\n", lat_information.rmt_node);
          printf("\t tty = %s\n", tty);
#endif
     }
     if (lat_information.rmt_port[0] != NULL) {
	  strcat(tty,"/");
     	  strcat(tty,lat_information.rmt_port);
#ifdef TESTING
          printf("\tPort Name = %s\n", lat_information.rmt_port);
          printf("\t tty = %s\n", tty);
#endif
     }

	return(tty);
}

#else

/************* Conditional not Digital UNIX and not Ultrix  *******************/

char *
checklat()
{
   return(0);
}

#endif  /* #elif defined __osf__ */

#endif /* DU_ULTRIX_LAT */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-04-15  4:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-04-15  4:26 SUMMARY: Obtaining LAT node/port, DU 3.2d Michael A. Crowley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox