.TITLE PSI$X29_DESTINATION_MACRO - X.29 EXAMPLE PROGRAM ; ;************************************************************************ ;* * ;* COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION, 1993 * ;* ALL RIGHTS RESERVED. UNPUBLISHED - RIGHTS RESERVED * ;* UNDER THE COPYRIGHT LAWS OF THE UNITED STATES. * ;* * ;* RESTRICTED RIGHTS LEGEND: USE, DUPLICATION, OR DISCLOSURE * ;* BY THE U.S. GOVERNMENT IS SUBJECT TO RESTRICTIONS AS SET * ;* FORTH IN SUBPARAGRAPH (C)(1)(II) OF DFARS 252.227-7013, * ;* OR IN FAR 52.227-19, OR IN FAR 52.227-14 ALT. III, AS * ;* APPLICABLE. * ;* * ;* THIS SOFTWARE IS PROPRIETARY TO AND EMBODIES CONFIDENTIAL * ;* TECHNOLOGY OF DIGITAL. POSSESSION, USE, OR COPYING OF THE * ;* SOFTWARE AND MEDIA IS AUTHORIZED ONLY PURSUANT TO A VALID * ;* WRITTEN LICENSE FROM DIGITAL. * ;* * ;************************************************************************ ; ;++ ; FACILITY: ; ; X.29 Destination Example Program ; ; ABSTRACT: ; ; Digital is furnishing this example software "as is" without ; warranty of any kind, express or implied, including the implied ; warranties of merchantability and fitness for a particular purpose. ; Digital disclaims any and all liability for the performance or ; non-performance of this software. ; ; ; This program is a simple example of an X.29 destination that ; asks the X.29 user for a password before allowing them to log in. ; ; The following NCL commands can be used to configure X.25. This ; configeration assumes the following ; - the estination example is started by a application entity ; - the file specified by the application entity contains a DCL ; command to run the destination executable. ; ; ; create x25 access ; create x25 client ; ! ; ! Create DTE classes ; ! ; create x25 access dte class crock type remote ; set x25 access dte class crock service node {(node=dundee, - ; rating=512)} ; create x25 access dte class crock1 type remote ; set x25 access dte class crock1 service node {(node=dundee, - ; rating=512)} ; ! ; ! Create security DTE class ; ! ; create x25 access security dte class default ; ! ; ! Create remote DTE entity ; ! ; create x25 access security dte class default remote dte match_all - ; remote address prefix * ; set x25 access security dte class default remote dte match_all - ; rights identifier {match_all} ; ! ; ! Create template ; ! ; create x25 access template net_template1 ; set x25 access template net_template1 dte class crock ; create x25 access template default ; ! ; ! Create filter ; ! ; create x25 access filter receive ; set x25 access filter receive incoming dte address 12345 ; ! ; ! Create security filter ; ! ; create x25 access security filter default ; set x25 access security filter default acl - ; {(identifier=(match_all),access=all)} ; ! ; ! Create application entity ; ! ; create x25 access application receive ; set x25 access application receive filters {receive} ; set x25 access application receive type x29 ; set x25 access application receive user system ; set x25 access application receive file sys$system:x25$destination.com ; ! ; ! Enable everything ; ! ; enable x25 access ; enable x25 client ; enable x25 access application receive ; ; FUNCTIONAL DESCRIPTION: ; ; * Declare local symbols ; * Assign a channel to NW ; * Assign a channel to mailbox ; * Read mailbox to obtain nv_unit and convert it to a ; device name string ; * Assign a channel to NV ; * Output a welcome message ; * Determine local echo mode from terminal characteristics ; if local echo mode make sure PAD echo parameter is turned off ; * Read the password from the terminal and validate it ; * If password was correct then clear the typeahead characteristics ; and set the temp nohang bit else deaccess NW ; * Deassign NV so that login will start on NV unit ; * Deassign channels to NW and mailbox ; ;-- .PAGE .SBTTL DEFINITIONS AND MACROS .ENABLE SUPPRESSION ; ; Include: ; .LIBRARY 'SYS$LIBRARY:PSILIB' ; ; Macro library calls ; $PSIDEF ; Define P.S.I. symbols $IODEF ; Define system i/o function codes $SSDEF ; Define status codes $TTDEF ; Define terminal characteristics ; ; Local data ; .psect data,rd,wrt,noexe IO_STATUS: .BLKQ 1 ; I/O staus block NW_CHAN: .BLKW 1 ; Channel to NW NV_CHAN: .BLKW 1 ; Channel to NV MBX_CHAN: .BLKW 1 ; Channel to mailbox NW_NAME: .ASCID /NWA0:/ ; NW device name NV_UNIT: .LONG 0 ; NV unit number NV_NAME: ; NV device name descriptor .LONG NV_NAME_LEN ; Length .ADDRESS NV_NAME_BUFFER ; Address NV_NAME_BUFFER: .BLKB 20 NV_NAME_LEN = .-NV_NAME_BUFFER MBX_NAME: .ASCID /SYS$NET/ ; Mailbox name FAO_CONTROL: .ASCID /!AC!UW:/ ; FAO control string TEMP_NOHANG_ON: .LONG 1 PAD_PARAM_BLOCK: .LONG PSI$K_X29_PAR_ECHO ; PAD echo parameter number .LONG 0 ; parameter value PAD_PARAM_LEN = .-PAD_PARAM_BLOCK ; ; Buffers ; TERM_CHAR: .BLKB 12 ; Buffer to get terminal ch'ristics TERM_CHAR_LEN = .-TERM_CHAR TERM_RCV_BUFF: .BLKB 40 ; Buffer to receive password TERM_RCV_LEN = .-TERM_RCV_BUFF WELCOME_MSG: .ASCII /Welcome to the X.29 example program/<10><13> ; Any welcome text desired WELCOME_LEN = .-WELCOME_MSG PWD_PRMPT: .ASCII /X.29 Password: / ; Prompt for password PWD_PRMPT_LEN = .-PWD_PRMPT PASSWORD: .ASCII /ABCDEFGH/ ; Correct password PASSWORD_LEN = .-PASSWORD MAILBOX: .BLKB 512 ; Mailbox buffer MAILBOX_LEN = .-MAILBOX .psect code,rd,exe,nowrt .PAGE .SBTTL MAIN ROUTINE .ENTRY PSI_X29_DESTINATION,^M<> ;+ ; Entry point ;- ;+ ; Assign channel to NW ;- $ASSIGN_S - ; Assign a channel DEVNAM = NW_NAME,- ; to NWA0 CHAN = NW_CHAN ; channel BSBW ERROR ; Check system service ;+ ; Assign channel to mailbox ;- $ASSIGN_S - ; Assign a channel DEVNAM = MBX_NAME,- ; to SYS$NET CHAN = MBX_CHAN ; channel BSBW ERROR ; Check system service .PAGE ;+ ; Read mailbox message (connect message) ;- $QIOW_S - ; QIO and wait CHAN = MBX_CHAN,- ; channel IOSB = IO_STATUS,- ; I/O status block FUNC = #IO$_READVBLK,- ; function is read P1 = MAILBOX,- ; buffer P2 = #MAILBOX_LEN ; and length BSBW IO_ERROR ; Check system service and iosb ;+ ; Get NV device unit number ;- MOVZWL MAILBOX+2,NV_UNIT ; Binary unit number .PAGE ;+ ; Convert unit number to device name string and ;- $FAO_S - ; Convert unit number CTRSTR = FAO_CONTROL,- ; FAO translation string OUTLEN = NV_NAME,- ; Length of device name OUTBUF = NV_NAME,- ; Buffer for device name P1 = #MAILBOX+4,- ; Device name counted string P2 = NV_UNIT ; Unit number BSBW ERROR ; Check system service ;+ ; Assign channel to NVAn: ;- $ASSIGN_S - ; Assign a channel DEVNAM = NV_NAME,- ; to NVAn: CHAN = NV_CHAN ; channel BSBW ERROR ; Check system service .PAGE ;+ ; Output welcome message ;- $QIOW_S - ; QIO and wait IOSB = IO_STATUS,- ; I/O status block CHAN = NV_CHAN,- ; NV channel FUNC = #IO$_WRITEVBLK,- ; function is write P1 = WELCOME_MSG,- ; buffer P2 = #WELCOME_LEN ; buffer length BSBW IO_ERROR ; Check system service and iosb .PAGE ;+ ; Read password ;- ;+ ; If terminal is in local echo mode, the NOECHO modifier to the read ; will have no effect so make sure the PAD echo parameter is off ;- $QIOW_S - ; QIO and wait CHAN = NV_CHAN,- ; NV channel IOSB = IO_STATUS,- ; I/O status block FUNC = #IO$_SENSEMODE,- ; read characteristics P1 = TERM_CHAR,- ; terminal characteristics buffer P2 = #TERM_CHAR_LEN ; length BSBW IO_ERROR ; Check system service and iosb BBC #TT2$V_LOCALECHO,TERM_CHAR+8,SKIP_PARAM_SET ; If not localecho, don't change ; ECHO parameter ;+ ; Make sure that the PAD echo parameter is turned off ;- $QIOW_S - ; QIO and wait CHAN = NW_CHAN,- ; NW channel IOSB = IO_STATUS,- ; I/O status block FUNC = #IO$_NETCONTROL,-; network control operation P1 = PAD_PARAM_BLOCK,- ; parameter descriptor block P2 = #PAD_PARAM_LEN,- ; length of block P3 = #PSI$K_X29_PAD_PARAMS,-; PAD parameter operation P4 = #PSI$K_X29_SET,- ; NV set operation P6 = NV_UNIT ; NV unit number BSBW IO_ERROR ; Check system service and iosb SKIP_PARAM_SET: ;+ ; Do the terminal read ;- $QIOW_S - ; QIO and wait CHAN = NV_CHAN,- ; NV channel IOSB = IO_STATUS,- ; I/O status block FUNC = #IO$_READPROMPT!IO$M_NOECHO!IO$M_CVTLOW,- - ; function is read with prompt - ; without echo - ; convert lower case to upper P1 = TERM_RCV_BUFF,- ; input buffer P2 = #TERM_RCV_LEN,- ; and length P5 = #PWD_PRMPT,- ; prompt buffer P6 = #PWD_PRMPT_LEN ; and length BSBW IO_ERROR ;+ ; Validate the password ; ; This code could be much more complex (looking up a coded form in a ; file, for example). ;- CMPC5 - ; Compare passwords IO_STATUS+2,TERM_RCV_BUFF,-; password entered #0,- ; fill with NUL #PASSWORD_LEN,PASSWORD ; correct password BEQL ACCEPT ; EQL - passwd correct, accept call BRW REJECT ; NEQ - passwd wrong, reject call .PAGE ACCEPT: ;+ ; Allow the user to log in ;- MOVL #SS$_NORMAL, R7 ; Exit status ;+ ; Clear the notypeahead characteristic ; ; Note that this requires PHY_IO privilege! ;- $QIOW_S - ; QIO and wait CHAN = NV_CHAN,- ; NV channel IOSB = IO_STATUS,- ; I/O status block FUNC = #IO$_SENSECHAR,- ; read permanent characteristics P1 = TERM_CHAR,- ; terminal characteristics buffer P2 = #TERM_CHAR_LEN ; length BSBW IO_ERROR ; Check system service and iosb BICL2 #TT$M_NOTYPEAHD,TERM_CHAR+4 $QIOW_S - ; QIO and wait IOSB = IO_STATUS,- ; I/O status block CHAN = NV_CHAN,- ; channel to NV FUNC = #IO$_SETCHAR,- ; set permanent characteristics P1 = TERM_CHAR,- ; characteristics buffer P2 = #TERM_CHAR_LEN,- ; and length P3 = IO_STATUS+2,- ; speed characteristics P4 = IO_STATUS+4 ; fill characteristics BSBW IO_ERROR ; Check system service and iosb ;+ ; Set the temp_nohang bit ;- $QIOW_S - ; QIO and wait IOSB = IO_STATUS,- ; I/O status block CHAN = NW_CHAN,- ; channel to NW FUNC = #IO$_NETCONTROL,-; function is net control P1 = TEMP_NOHANG_ON,- ; value to set P2 = #4,- ; longword P3 = #PSI$K_X29_TEMP_NOHANG,-; affect NV temp_nohang param P4 = #PSI$K_X29_SET,- ; NV set operation P6 = NV_UNIT ; NV unit number BSBW IO_ERROR ; Check system service and iosb ;+ ; Deassign channel to NV, login will start on the NV unit ;- DEASSIGN: $DASSGN_S - ; Deassign channel CHAN = NV_CHAN ; channel to NV BSBW ERROR ; Check system service ;+ ; Deassign other channels ;- $DASSGN_S - ; Deassign channel CHAN = NW_CHAN ; channel to NW BSBW ERROR ; Check system service $DASSGN_S - ; Deassign channel CHAN = MBX_CHAN ; channel to mailbox BSBW ERROR ; Check system service ;+ ; Exit ;- $EXIT_S - ; Exit CODE = R7 ; with status .PAGE REJECT: ;+ ; Password was incorrect so clear call ;- MOVL #SS$_ABORT,R7 ; Exit status $QIOW_S - ; QIO and wait IOSB = IO_STATUS,- ; I/O status block CHAN = NW_CHAN,- ; channel to NW FUNC = #IO$_DEACCESS,- ; function is clear call P6 = NV_UNIT ; on NV terminal BSBW IO_ERROR ; Check system service and IOSB ;+ ; When the NV channel is deassigned, the NV unit will disappear ;- BRB DEASSIGN ; Branch to common exit code .PAGE .SBTTL ERROR CHECKING SUBROUTINES ;+ ; If any errors occur, the program exits with the error status ;- IO_ERROR: .jsb_entry ; Check I/O status block BLBC R0,IO_ERR_EXIT ; If lbc, error MOVZWL IO_STATUS,R0 ; else, check I/O status BLBS R0,IO_ERR_RET ; If not lbc, return IO_ERR_EXIT: $EXIT_S - ; Error occurred - exit CODE = R0 ; with status. IO_ERR_RET: RSB ERROR: .jsb_entry BLBC R0,ERR ; If lbc, error RSB ; No errors found - return ERR: $EXIT_S - ; Error occurred - exit CODE = R0 ; with status. .END PSI_X29_DESTINATION ; Start of main routine