.TITLE TIMSND - DECnet Time Sender .IDENT /Y01.03/ ; In-house version .NLIST BEX ; Don't list binary extensions .ENABL LC ; Enable lower case .SBTTL Introduction ; ; TIMSND - DECnet Network Master Time Server/Sender Task ; ; Companion file to TIMREC, network time requester/setter task ; Author: ; Bruce R. Mitchell ; Source Site: ; Machine Intelligence and Industrial Magic ; PO Box 601, Hudson, Wisconsin 54016 ; Source Hardware and Operating System: ; DEC PDP-11/70 under RSX-11M-Plus V2.0 Autopatch A ; Target Site: ; Same ; Target Hardware and Operating System: ; Same ; Revision History: ; 1-Sep-82 First version coded ; 17-Nov-82 Error message handling changed .PAGE .SBTTL .SBTTL TIMSND Structure ; ; TIMSND is simply structured. It is installed on the network master ; node as object 201. When "woken up" by a DECnet request, it ; gets the connect data block, accepts the connect, and ships the ; host system time back to the requesting task in the connection ; "mailbox". It logs the request on the console, and then exits. ; .PAGE .SBTTL Caveats - READ THESE! ; TIMSND is not very particular about who it talks to; regardless ; of the information that was specified to be sent in the remote ; task's connect request, TIMSND cheerfully accepts the connection ; and sends back the system time. ; ; The TIMREC task expects to connect to TIMSND an an object, not a ; task. The TIMSND task, therefore, must be installed on the master ; node and defined as an object. This is done as follows: ; ; NCP SET OBJECT 201 NAME TIMSND USER DEFAULT VERIFICATION OFF ; ; ; This is SEMI-SUPPORTED and EXPERIMENTAL software which may ; do any number of foul things to the system on which it runs. ; Don't come bitching about anything this task does to you. ; Caveat user. .PAGE .SBTTL .SBTTL Macro Calls and Definitions ; Macros from LB:[1,1]NETLIB.MLB .MCALL ACCW$ ; Accept a connect and wait .MCALL CLSW$ ; Close the network and wait .MCALL DSCW$ ; Disconnect from object and wait .MCALL GNDW$ ; Get network data and wait .MCALL NETDF$ ; Network definitions .MCALL OPNW$ ; Open network and wait NETDF$ ; Define the network symbols ; Macros from LB:[1,1]RSXMAC.SML .MCALL ALUN$ ; Assign logical unit number .MCALL DIR$ ; Execute system directive .MCALL EXST$ ; Exit with status .MCALL GTIM$ ; Get system time .MCALL QIOSY$ ; Define QIO symbols .MCALL QIOW$ ; Queue I/O and wait QIOSY$ ; Define the QIO symbols .PAGE .SBTTL Local Definitions LUN1 = 1 ; LUN for network mailbox LUN2 = 2 ; LUN for logical links LUN3 = 3 ; LUN for system console EFN1 = 1 ; EFN for network mailbox EFN2 = 2 ; EFN for logical links EFN3 = 3 ; EFN for system console .PAGE .SBTTL Directive Parameter Blocks ; DPB for accepting a connect from a remote task ACCNET: ACCW$ LUN2, EFN2, NSTBLK,, ; Get data on LUN 2 ; Waiting event flag is EFN 2 ; NSTBLK is the GND status block ; MAIBLK is the connect mail block ; Length of connect mail block 16 bytes ; TIMRET is the return mail buffer ; Length of mail buffer is 16. bytes ; DPBs for assigning LUNs to the network ALUN1: ALUN$ LUN1, NS, 0 ; Assign LUN 1 to NS: unit 0 ALUN2: ALUN$ LUN2, NS, 0 ; Assign LUN 2 to NS: unit 0 ALUN3: ALUN$ LUN3, CO, 0 ; Assign LUN 3 to CO: unit 0 ; DPB for closing the network CLSNET: CLSW$ LUN1, EFN1 ; Close all activity on LUN 1 ; Waiting event flag is EFN 1 ; DPB for disconnecting from requester task on requester node DISNET: DSCW$ LUN2, EFN2 ; Disconnect from server on LUN 2 ; Waiting event flag is EFN 2 ; DPB for exiting with status EXSTAT: EXST$ EX$SUC ; For exiting with success status EXSTER: EXST$ EX$ERR ; For exiting with error status ; DPB for getting unsolicited network data GETNET: GNDW$ LUN1, EFN1, NSTBLK,, ; Get data from LUN 1 ; Waiting event flag is EFN 1 ; NSTBLK is the status block ; MAIBLK is the "mail" block ; MAIBLK is 98 bytes long ; DPB for getting system time GETTIM: GTIM$ TIMRET ; Time block address is TIMRET ; DPB for opening the network OPENET: OPNW$ LUN1, EFN1, NSTBLK,, <1, 0> ; Open network on LUN 1 ; Waiting event flag is EFN 1 ; NSTBLK is the open status block ; Maximum of 1 logical link open ; Abort log. link on phys. link failure ; DPB for printing a message on the console TIQBLK: QIOW$ IO.WVB, LUN3, EFN3,,,, < , , 40> ; Brkthru write on CO: .PAGE .SBTTL Message Storage MESG01: .BLKB 8. ; 8 bytes for storing time .ASCII \ TIMSND - Time request from node \ .EVEN MS1NOD: .BLKW 3 ; Storage for node name MS1LEN = . - MESG01 MESG02: .BLKB 8. ; 8 bytes for storing time .ASCII \ TIMSND-F-NGF, Network get data failed\ MS2LEN = . - MESG02 MESG03: .BLKB 8. ; 8 bytes for storing time .ASCII \ TIMSND-F-NOF, Network open failed\ MS3LEN = . - MESG03 MESG04: .ASCII \ I/O status code = \ MS4A: .BLKB 3 .ASCII \, $DSW = \ MS4B: .BLKB 3 MS4LEN = . - MESG04 .EVEN .PAGE .SBTTL Variable Storage MAIBLK: .BLKB 98. ; 98 bytes for incoming connect block NSTBLK: .BLKW 2 ; 2 words for network status block TIMRET: .BLKW 8. ; 8 words for returned time .PAGE .SBTTL .SBTTL Code TIMSND: DIR$ #ALUN1 ; Assign first network LUN DIR$ #ALUN2 ; Assign second network LUN DIR$ #ALUN3 ; Assign LUN to CO: DIR$ #GETTIM ; Get system time in case any DIR fails DIR$ #OPENET ; Open the network CMPB NSTBLK, #IS.SUC ; Was the open successful? BEQ 10$ ; If so, continue ; Network open failed; print message stating same and exit w/status MOV #MESG03, R0 ; Load ASCII time field address in R0 MOV #TIMRET+G.TIHR, R1 ; Load binary time field address in R1 MOV #3, R2 ; Specify HH:MM:SS format CALL $TIM ; Convert time to ASCII MOV #MESG03, R3 ; "TIMSND-F-NOF, Network open failed" MOV #MS3LEN, R4 ; Load message length into R4 MOV NSTBLK, R5 ; Load error code into R5 CALL ERREXT ; Print the error code and message DIR$ #EXSTER ; Exit with error status ; The network is opened; get network data about the requester 10$: DIR$ #GETNET ; Try to get network data CMPB NSTBLK, #IS.SUC ; Was the get successful? BEQ 20$ ; If so, continue ; Get network data failed; write error message and die in disgrace MOV #MESG02, R0 ; Load ASCII time field address in R0 MOV #TIMRET+G.TIHR, R1 ; Load binary time field address in R1 MOV #3, R2 ; Specify HH:MM:SS format CALL $TIM ; Convert time to ASCII MOV #MESG02, R3 ; "TIMSND-F-NGF, Network get data ..." MOV #MS2LEN, R4 ; Load message length into R4 MOV NSTBLK, R5 ; Load error code into R5 CALL ERREXT ; Print the error code and message DIR$ #EXSTER ; Exit with error status ; Get was successful; accept the connection and spit back the time 20$: DIR$ #GETTIM ; Get system time MOV #-1, TIMRET+S.TICP ; Default the clock frequency DIR$ #ACCNET ; Accept the connection DIR$ #DISNET ; Disconnect from the server DIR$ #CLSNET ; Close the network ; Make a note of the time and requester on the system console MOV #MESG01, R0 ; Load ASCII time field address in R0 MOV #TIMRET+G.TIHR, R1 ; Load binary time field address in R1 MOV #3, R2 ; Specify HH:MM:SS format CALL $TIM ; Convert time to ASCII MOV MAIBLK+N.SND, MS1NOD ; Move 1st 2 bytes of node name MOV MAIBLK+N.SND+2, MS1NOD+2 ; Move 2nd 2 bytes of node name MOV MAIBLK+N.SND+4, MS1NOD+4 ; Move 3rd 2 bytes of node name MOV #MESG01, TIQBLK+Q.IOPL ; Move time request message into DPB MOV #MS1LEN, TIQBLK+Q.IOPL+2 ; Move message length into DPB DIR$ #TIQBLK ; Print error message on TI: DIR$ #EXSTAT ; Exit with success status .PAGE .SBTTL .SBTTL Subroutines .SBTTL .SBTTL ERREXT Print Error Codes ; ; ERREXT - Print I/O Error and $DSW Error ; ; This subroutine prints an error message, the I/O status code, and ; the $DSW error code. ; ; Inputs: R3 - Address of preceding error message ; R4 - Length of preceding error message ; R5 - Directive I/O error code value ; ; Outputs: None ; ; Register dispositions: All registers used are saved and restored ; ; Variable dispositions: None modified ; ERREXT: CALL $SAVAL ; Save registers 0 - 5 MOV $DSW, -(SP) ; Save the DSW on the stack MOV R3, TIQBLK+Q.IOPL ; Punch in the message address MOV R4, TIQBLK+Q.IOPL+2 ; Punch in the message length DIR$ #TIQBLK ; Print the preceding error message MOV #MS4A, R0 ; R0 points at the target storage area MOVB R5, R1 ; R1 contains the source byte CLR R2 ; Specify suppression of leading zeroes CALL $CBTMG ; Convert binary byte to octal magnitude MOV #MS4B, R0 ; R0 points at the target storage area MOV (SP)+, R1 ; Restore the DSW into R1 CLR R2 ; Specify suppression of leading zeroes CALL $CBTMG ; Convert binary byte to octal magnitude MOV #MESG04, TIQBLK+Q.IOPL ; Punch in the message address MOV #MS4LEN, TIQBLK+Q.IOPL+2 ; Punch in the message length DIR$ #TIQBLK ; Print the preceding error message RETURN ; Return to the caller .END TIMSND