From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX"  9-JUN-1992 01:10:37.95
To:	info-vax@kl.sri.com
CC:	
Subj:	Re: Dial-back modem access

boss@geovax.ed.ac.uk (Bruce Gittings) writes:
> Does anyone have a program which will cause a modem attached to VAX/VMS
> to dial back to the caller, thus charging my employers rather than myself?

Well, I didn't, but decided it would be an interesting problem to solve.

The attached routine uses a DTEPAD compatible dialler to do what I think 
you want.  Just compile it, and link against your dialler.  (It works 
well with DTE_HAYES, which I posted a while ago.  Sing out if you 
haven't already got it -- assuming of course you have Hayes combatible 
modems!)

Install the brute with SHARE and LOG_IO (see the comments as to why/if 
these privileges are needed), then run it.  It will ask for a phone 
number to dial you back on, drop the line and call you (hopefully!).  You 
will have to log back in, but if you have virtual terminals enabled, you 
can reconnect to your session.

It can be used as a foreign command, for use in command files etc (in 
case you want to use it for security dialback or as part of a menu, 
buried in a login procedure or something).

Note that it doesn't work on LAT ports -- I don't have a terminal server
on hand to test it with.  It will work with virtual terminals (VTAnnnn:s)
however. 

To install:

        $ MACRO DIALBACK
        $ MACRO DTE_HAYES                       ! Or whatever -- BYO
        $ LINK/NOTRACE DIALBACK,DTE_HAYES
        $ COPY DIALBACK.EXE disk:[dir]
        $ INSTALL disk:[dir]DIALBACK/PRIVILEGES=(SHARE,LOG_IO)

Enjoy.


Don Stokes, ZL2TNM (DS555)                       don@zl2tnm.gen.nz (home)
Network Manager, Computing Services Centre           don@vuw.ac.nz (work)
Victoria University of Wellington, New Zealand             +64-4-495-5052

		.title DIALBACK		Quick-n-dirty to dial back a number
;++
;
; This routine provides dialback for incoming modems
; Install with LOG_IO if the TT2$M_MODHANGUP bit is not set in the sysgen
; parameter TTY_DEFCHAR2.  Installing with SHARE privilege also allows it
; to cut through any spurious logins that might have grabbed the port as
; a result of the hangup.
;
; The module is intended to be linked against any dialler module compatible
; with SET HOST/DTE.  However, watch for messages produced during the dial,
; as these may be sent out the modem port!  Ask me if you need a Hayes 
; compatible dialler module.
;
; To run, set up as a foreign command.  It takes one parameter, the phone
; number to dial back.
;
; This will _not_ work on LAT ports (or any others that destroy the device
; when the last channel is deassigned), since it lets the port go completely
; before picking it up again and dialling.
;
;	Don Stokes, don@zl2tnm.gen.nz			8-Jun-1992.  
;
; Guarantee: If it breaks, you get to keep both halves.
;
;--



;
; Status macro.
;
		.macro status code, ?L1
		blbs code, L1
		$EXIT_S code
L1:		.endm


		.psect data, long,noshr,noexe,wrt
;
; Data things
;
number:		.word 0			; Dynamic descriptor for phone no
		.byte DSC$K_DTYPE_T
		.byte DSC$K_CLASS_D
		.long 0
prompt:		.ascid "Number: "	; Prompt for same

chan:		.blkl			; Channel for terminal
iosb:		.blkw 4			; Dogsbody IOSB
tty:		.ascid "SYS$COMMAND:"	; TTY name

dvi_itmlst:	.word 16		; Item list for getting physical device
		.word DVI$_TT_PHYDEVNAM	; name
		.address port_buf
		.address port
		.long 0			; End of itmlst

port:		.blkw 			; Descriptor to phydevnam
		.byte DSC$K_DTYPE_T
		.byte DSC$K_CLASS_S
		.address port_buf

port_buf:	.blkb 16		; Buffer for same

chars:		.blkb 12		; Port characteristics buffer

delay:		.float 5.		; Delay period before hitting modem



		.psect code, long,nowrt,exe,shr
;
; Main routine
;
dialback::	.word ^M<>
;
; Get number from command line
;
		pushaq prompt
		pushaq number
		calls #2, g^LIB$GET_FOREIGN
		status R0
;
; Assign channel to terminal
;
		$ASSIGN_S chan=chan, devnam=tty
		status R0
;
; Get the real name of the terminal
;
		$GETDVIW_S chan=chan, itmlst=dvi_itmlst, iosb=iosb
		status R0
		status iosb
;
; Hang up the line
;
		$QIOW_S chan=chan, iosb=iosb, func=#IO$_SETMODE!IO$M_HANGUP
		status R0
		status iosb
;
; Deassign channel, then re-assign to saved name after a short delay
;
		$DASSGN_S chan=chan
		status R0
		pushaf delay
		calls #1, g^LIB$WAIT
		status R0
		$ASSIGN_S chan=chan, devnam=port
		status R0
;
; Tweak HANGUP bit off in terminal characteristics so modem stays online
; when we let go.
;
		$QIOW_S chan=chan, iosb=iosb, func=#IO$_SENSEMODE, -
			p1=chars, p2=#12
		status R0
		status iosb
		bicl2 #TT2$M_HANGUP, chars+8
		$QIOW_S chan=chan, iosb=iosb, func=#IO$_SETMODE, -
			p1=chars, p2=#12
		status R0
		status iosb
;
; Call dialer module to dial number
;
		pushl chan
		pushl chan
		pushaq number
		calls #3, g^DIAL_ROUTINE
;
; All done
;
		ret

		.end dialback

