.TITLE X25$RECEIVE_MACRO P.S.I. Example Program. .ENABL SUPPRESSION ;************************************************************************ ;* * ;* 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.25 Example Program ; ; ABSTRACT: ; ; RECEIVE PROGRAM ; ; 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 intended to run with the send example programes. ; Data is entered via the terminal to the send program, and sent by ; X.25 to the receive program. ; ; The following NCL commands can be used to configure X.25. This ; configeration assumes the following ; - the send and recieve programs are running on the same system ; - the same gateway is used to place and outgoing call and recieve ; - the incomming call. ; - the recieve example is started from DCL before the send program ; ; ; 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)} ; ! ; ! Enable everything ; ! ; enable x25 access ; enable x25 client ; ; ; ; FUNCTIONAL DESCRIPTION: ; ; * Include library files and declare local variables ; * Assign a mailbox for the network device ; * Assign an input/output (I/O) channel to the network ; device (NWA0:) ; * Ask to receive a specific sub-address ; * Wait until a connection request appears in mailbox ; * Accept the connection ; * Loop reading data until control-z received ; * Clear the call ; * Deassign the mailbox and I/O channels ; ;-- .PAGE .SBTTL Definitions and Macros ;+ ; Macro Libraries: ;- .LIBRARY "SYS$LIBRARY:PSILIB" ; P.S.I. Library PM002 .LIBRARY "SYS$LIBRARY:LIB.MLB" ;+ ; Definitions: ;- $IODEF ; I/O Function Codes $MSGDEF ; Mailbox Message Codes $PSIDEF ; P.S.I. Codes $SSDEF ; System Service Codes $PRVDEF ; Privileges $NFBDEF ; NFB definitions .psect data,noexe,rd,wrt .MACRO $NCB I1,V1,I2,V2,I3,V3,I4,V4,?L1,?L2,?L3,?L4,?END .LONG END-8-. .ADDRESS .+4 .IF NB I1 .WORD L1-. .WORD I1 V1 L1: .ENDC .IF NB I2 .WORD L2-. .WORD I2 V2 L2: .ENDC .IF NB I3 .WORD L3-. .WORD I3 V3 L3: .ENDC .IF NB I4 .WORD L4-. .WORD I4 V4 L4: .ENDC END: .ENDM $NCB .PAGE .SBTTL Own Storage ;+ ; RMS Control Blocks for Output Stream: ;- X25R_FAB: ; File Access Block $FAB - FNM = ,- ; Filename RAT = ,- ; Record attributes FAC = ; Access mode X25R_RAB: ; Record Access Block $RAB - FAB = X25R_FAB ; FAB Address ;+ ; Miscellaneous Buffers &c: ;- IO_STATUS: ; I/O status block .BLKQ 1 PSI_CHAN: ; Network device channel .BLKW 1 MBX_CHAN: ; Mailbox channel .BLKW 1 PSI_DEV: ; Network device name .ASCID /_NWA0:/ MBX: ; Mailbox logical name .ASCID /ANY_NAME_YOU_WANT/ RCV_BUF: ; Receive buffer .BLKB 200 RCV_LEN = .-RCV_BUF MBXBUF: ; Mailbox buffer .BLKB 200 MBXBUFSIZ = .-MBXBUF ACCEPT_NCB: ; Descriptor for NCB .BLKQ 1 PRIVS: .LONG 1@PRV$V_EXQUOTA,0 ; Additional privs required ;+ ; Control blocks for ACPCONTROL ;- NFB01: .LONG 5 .ADDRESS .+4 .BYTE NFB$C_DECLNAME .LONG 0 ; NTD for ACPCONTROL NTD01: $NCB PSI$C_NTD_ACCLVL,<.ASCIC /X25L3/>,- PSI$C_ntd_flt_pri,<.WORD 150> .PAGE .SBTTL Main Line Routine .psect code,exe,rd,nowrt .ENTRY EXA$PSI_RECEIVE,^M<> ;+ ; Entry Point - Initialise output file. ;- $OPEN - ; Open output file FAB = X25R_FAB $CONNECT - ; and connect record stream RAB = X25R_RAB BSBW ERROR ; Check for error $SETPRV_S - ; Program may exceed quota ENBFLG = #1,- ; Set the privileges on PRVADR = PRIVS ; Address of 64-bit field ;+ ; Create network device mailbox and assign network channel. ;- $CREMBX_S - ; Create mailbox CHAN = MBX_CHAN,- ; channel LOGNAM = MBX ; logical name BSBW ERROR ; Check for error $ASSIGN_S - ; Assign a channel DEVNAM = PSI_DEV,- ; to network device CHAN = PSI_CHAN,- ; channel number MBXNAM = MBX ; mailbox logical name BSBW ERROR ; Check for error ;+ ; Ask to receive a specific sub-address ;- $QIOW_S - CHAN = PSI_CHAN,- ; Channel FUNC = #IO$_ACPCONTROL,- ; Function IOSB = IO_STATUS,- ; I/O status block P1 = NFB01,- ; Network function block P2 = #NTD01 ; Network declaration block BSBW IO_ERROR ; Check for i/o error ;+ ; Read connect message from mailbox and accept call. The NCB is stored ; in the information field of the standard mailbox device message as a ; counted string. ;- $QIOW_S - ; Issue QIO and wait CHAN = MBX_CHAN,- ; to the mailbox FUNC = #IO$_READVBLK,- ; function is read IOSB = IO_STATUS,- ; I/O status block P1 = MBXBUF,- ; buffer address P2 = #MBXBUFSIZ ; and its size BSBW IO_ERROR ; Check for I/O error MOVZBL MBXBUF+20,ACCEPT_NCB ; Store NCB size MOVAB MBXBUF+21,ACCEPT_NCB+4 ; and NCB address ;+ ; . ; . ; . MOVZWL IO_STATUS+2, -(SP) PUSHAB MBXBUF ; Code to analyse NCB and decide whether to accept call. ; . ; . ; . ;- $QIOW_S - ; Issue QIO and wait CHAN = PSI_CHAN,- ; to the network device FUNC = #IO$_ACCESS!IO$M_ACCEPT,- ; function is accept call IOSB = IO_STATUS,- ; I/O status block P2 = #ACCEPT_NCB ; NCB descriptor address BSBW IO_ERROR ; Check for I/O error .PAGE .SBTTL Loop to Receive Messages. ;+ ; This loop reads a message from the remote process and writes it to the ; output file. When an end-of-file message is received, the call is ; cleared. ;- READ_MESSAGE: $QIOW_S - ; Issue a QIO and wait CHAN = PSI_CHAN,- ; to the network device FUNC = #IO$_READVBLK,- ; function is read IOSB = IO_STATUS,- ; I/O status block P1 = RCV_BUF,- ; receive buffer P2 = #RCV_LEN ; and its length BSBW IO_ERROR ; Check for I/O error BBS #PSI$V_QUALIFIED,IO_STATUS+4,CLEAR_CALL ; If Q, clear down MOVAB RCV_BUF,X25R_RAB+RAB$L_RBF ; Else, store buffer adrs MOVW IO_STATUS+2,X25R_RAB+RAB$W_RSZ ; and size for RMS $PUT - ; Write buffer RAB = X25R_RAB ; to the output file BSBW ERROR ; Check for error ;+ ; Continue until end of messages. ;- BRB READ_MESSAGE ; Continue .PAGE .SBTTL Clear the Call ;+ ; An end of file message was received from the remote process on the ; qualified data channel. Clear the call, and de-assign the I/O channels. ;- CLEAR_CALL: ;+ ; First, acknowledge receipt of the end-of-data indication. ;- $QIOW_S - ; Issue a QIO and wait CHAN = PSI_CHAN,- ; to the network device FUNC = #IO$_WRITEVBLK!IO$M_QUALIFIED,- ; Write, Q-bit set IOSB = IO_STATUS,- ; I/O status block P1 = RCV_BUF,- ; return ^Z that were sent P2 = #1 ; and its length BSBW IO_ERROR ; Check for I/O error ;+ ; Await the clearing down of the link from the other end. ;- $QIOW_S - ; Issue a QIO and wait CHAN = PSI_CHAN,- ; to the network device FUNC = #IO$_READVBLK,- ; function is read IOSB = IO_STATUS,- ; I/O status block P1 = RCV_BUF,- ; receive buffer P2 = #RCV_LEN ; and its length CMPW IO_STATUS,#SS$_CLEARED ; Link should now be clear BEQL CONTINUE ; If not, there's an error CLRL R0 BSBW ERROR CONTINUE: $QIOW_S - ; Issue QIO and wait CHAN = PSI_CHAN,- ; to the network device FUNC = #IO$_DEACCESS,- ; function is clear call IOSB = IO_STATUS ; I/O status block BSBW IO_ERROR ; Check for I/O error $DASSGN_S - ; Deassign channel CHAN = PSI_CHAN ; to network device BSBW ERROR ; Check for error $DASSGN_S - ; Deassign channel CHAN = MBX_CHAN ; to mailbox BSBW ERROR ; Check for error ;+ ; Exit successful. ;- $EXIT_S - CODE = #SS$_NORMAL ; Exit ret ; with success status .PAGE .SBTTL Routine to Check Return Status ;+ ; This routine checks the I/O status and system service return codes. ; If an error is found the program exits. ;- 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 EXA$PSI_RECEIVE ; End of module