Article 135703 of comp.os.vms:
Path: nntpd.lkg.dec.com!crl.dec.com!crl.dec.com!bloom-beacon.mit.edu!apollo.hp.com!lf.hp.com!news.dtc.hp.com!col.hp.com!usenet.eel.ufl.edu!news.mathworks.com!uunet!in1.uu.net!usc!news.cerf.net!mvb.saic.com!info-vax
From: Alan Simon <simon@shrsys.hslc.org>
Newsgroups: comp.os.vms
Subject: RE: AXP/VMS accounting on LAT connected modem lines.
Message-ID: <0099A86F.81C682C9.149@shrsys.hslc.org>
Date: Thu, 07 Dec 1995 21:00:30 EST
Organization: Info-Vax<==>Comp.Os.Vms Gateway
X-Gateway-Source-Info: Mailing List
Lines: 197

> From:	MX%"gmacdougall@ivory.trentu.ca"  7-DEC-1995 17:15:33.43
> Subj:	AXP/VMS accounting on LAT connected modem lines.

> 
> 	Open VMS6.2 on an alpha 2100/275
> 	
> 	I have about 40 modems connected through decserver 200's. I would like
> to keep accounting info on their use. Previously on a VAX I had used a small
> bit of macro code written by Kevin Homan of Science Applications, Inc. called
> log_port.mar which stuffed the server name into the "Remote Node Name" field,
> and the port name into the "Remote Node ID" field of the accounting record.
> It worked but I'm wondering if there is a better way these days. The code does
> not compile on the AXP and I am not comfortable touching cmkrnl code. 
> 	I did try creating LAT ports in advance and assigning them to specific 
> servers and ports in the hopes that all connects from port 4 on server xxx1 
> would use lta2001 but I was unsuccessful. Since I have several vaxen, an alpha 
> and several decstations I can not dedicate server ports to specific hosts.
> 	I would be very grateful for ideas.
> 
> 							George MacDougall
> 							gmacdougall@trentu.ca
> 							
> 	Computing and Telecommunications Department - (705) 748-1602
>         Trent University - Peterborough, Ontario - K9J 7B8

Well, here's LOG_PORT V2, re-written in C and which compiles on AXP:

/*
;+
;
; ----	LOG_PORT:	Process' terminal server and port logging 
;
;
; Facility:
;
;	VAX/VMS system management
;
; Environment:
;
;	OPENVMS VAX V5.5-2 or OPENVMS AXP 1.5 or later, kernel mode
;	Tested under VAX C and DEC C (on AXP)
;
; Compiling:
;$ cc log_port
;
; Linking:
;$ If f$getsyi("ARCH_NAME") .EQS. "Alpha"
;$  Then
;$	link/notrace/exec=log_port_alpha.exe log_port,sys$input/opt
;sys$loadable_images:sys$base_image.exe/share
;$  Else
;$	link/notrace log_port,sys$input/opt
;sys$share:vaxcrtl.exe/share
;sys$system:sys.stb/selective_search
;$ EndIf
;
; Installing:
;$   if f$getsyi("ARCH_NAME") .NES. "Alpha"
;$    Then
;$	install create SYS$SYSTEM:LOG_PORT.EXE/OPEN/HEAD/SHARE/PRIV=(CMKRNL)
;$    Else
;$	install create SYS$SYSTEM:LOG_PORT_ALPHA.EXE/OPEN/HEAD/SHARE/PRIV=(CMKRNL)
;$   EndIf
;
;	
; Running:
;$ If f$getsyi("ARCH_NAME") .EQS. "Alpha"
;$  Then
;$	If "''F$MODE()'" .eqs. "INTERACTIVE" Then run sys$system:log_port
;$  Else
;$	If "''F$MODE()'" .eqs. "INTERACTIVE" Then run sys$system:log_port_alpha
;$  EndIf
;
; Abstract:
;	This routine will extract the current process' terminal server
;	name and port id, if it is a lat process.   This information will
;	the be stored in the remote node name and remote node id fields of 
;	the process' P1.  These fields are normally only used by RTTDRIVER
;	and REMACP for remote process', hence no prblm.  These fields are
;	however written by the system accounting facility and will provide
;	a convenient means for storing and tracking this information.
;
; Version:     	V02.000
; Date:		7-Aug-1994
;                         
; Kevin	F. Homan 12-JAN-1990
; Science Applications, Inc.
; 800 Oak Ridge Turnpike
; Oak Ridge, TN  37830
; (615) 482-9031
;
;
; Modifications:
;
;	16-Nov-1987	kfh	Initial creation
;
;	7-Aug-1994	kfh	Converted to C and modified to run under alpha
;                                                     
;-                                                    
*/
#include <string.h>
#include <starlet.h>
#include <lib$routines.h>
#include <stdio.h>
#include <descrip.h>
#include <dvidef.h>

/* storage areas for server and port */
  unsigned char serverlen, portlen;
  char		*server, *port;


int main()
{

  long int status;     
  struct   /* io status block */
    {
      long condition;
      long ignored;
    } iosb;

  $DESCRIPTOR (dev_name_desc,"tt"); /* terminal device */
  int move_info();
  char			*ptr;
  static  char		buffer[129];
  static $DESCRIPTOR(device_name,buffer);

/* standard item list structure */
  struct
  {
  short	int		buf_len;
  short	int		item;
  char			*buf_addr;
  unsigned short int	*ret_len;
  int			end;
  }item_list = {device_name.dsc$w_length, DVI$_TT_ACCPORNAM,
	     device_name.dsc$a_pointer, 
	     &device_name.dsc$w_length, 0};

  memset(buffer,0,129); /* init buffer */

/* get real device name */
  status = sys$getdviw( 0,0,&dev_name_desc,&item_list,&iosb,0,0,0);

/* check for success */
  if (! (status & 1)) lib$stop (status);
  if (! (iosb.condition)) lib$stop (status);

/* check for slash separating the server name from the port name */
/* if there is no slash then this is not a terminal server */
  if ((ptr = strrchr(buffer,'/')) != NULL) {
	server = buffer;	/* the server is first place in buffer */
	port = ptr+1;		/* separated with a slash is the port */
	*ptr = 0;		/* zero terminate server string */
	serverlen = strlen(server);	/* store server name length */
	portlen = strlen(port);		/* ditto for port name */
	if (serverlen > 6) serverlen = 6;	/* only room for six char */
	if (portlen > 16) portlen = 16;	/* sixteen in the remoteid field */

#ifdef DEBUG
	printf("server %s \n",server);
	printf("port %s \n",port);
#endif
	status = sys$cmkrnl(move_info,0);
	(void) sys$exit(status); 
	}
}

int move_info()
{
#ifdef __DECC
  #pragma extern_model save
  #pragma extern_model strict_refdef
  extern char ctl$t_nodename;
  extern char ctl$t_remoteid;
  #pragma extern_model restore
#else /* VAXC */
  globalref char ctl$t_nodename;
  globalref char ctl$t_remoteid;
#endif

  lib$establish(lib$sig_to_ret);	 /* for the hackers */
  strncpy((char *)&ctl$t_nodename+1,server,serverlen);	/* store server */
  strncpy((char *)&ctl$t_remoteid+1,port,portlen);	/* store port */
  ctl$t_nodename = serverlen;		/* its counted string */
  ctl$t_remoteid = portlen;		/* so store the lengths */
  return(1);				/* always seems to work? */
}

-------------------------------------------------------------------------------
Alan Simon                                      simon@hslc.org  
Associate Director                              simon@shrsys.hslc.org
Health Sciences Libraries Consortium            VOICE: (215) 222-1532  
3600 Market Street, Suite 550                     FAX: (215) 222-0416
Philadelphia, PA  19104
-------------------------------------------------------------------------------


