.title LOOPX .ident /V01-002/ ; © 2000 P. Beaudoin ; This software is supplied as is and the usual warranty ; is implied - none. You may use, abuse, modify or ; or ignore this software as you see fit but are ; encouraged to give credit, as is good practice ; when stealing with permission ; ;++ ;1 LOOPX ; This program is designed to transmit a 802.3 class 1 XID packet ; to the selected address with the POLL bit set. Any 802.3 compliant ; node on the Ethernet should respond to the frame with a XID packet ; having the FINAL bit set. ; Thanks to: ; Clyde C. Smith - Sr. System Engineer ; DECnet/VAX support ; Network Systems Group, Colorado Springs Colorado ; ;2 Input ; P1 .address of 6 byte Ethernet address of target node ; P2 (opt).address of .long Stats ;2 Output ; If P2 is specified, it is written with the response time in 1/100 units. ; ;2 Return ; SS$_NORMAL All Requested loops were succesful ; SS$_BADPARAM Input param error: ; Number of params was .NE. 1 or .NE. 2 ; SS$_UNREACHABLE Failed to receive loop response from target ; SS$_ACCVIO Can' read input params or can't write outp field ;-- ; Data .PSECT DATA,WRT,NOEXE,QUAD .LIBRARY "SYS$LIBRARY:LIB.MLB" $IODEF ; I/O functions $NMADEF ; Network Management Functions ; Local Definitions ; ;Arg lists for $QIO WRITE_IT: .LONG 12 ; No. of args .LONG 0 ; Event ETHCHN: .LONG 0 ; Channel .LONG IO$_WRITEVBLK ; Function .LONG IOSB ; Pointer to IOSB .LONG 0 ; AST Address .LONG 0 ; AST Param .LONG XMTBUF ; P1 .LONG XMTBUFLEN ; P2 .LONG 0 ; P3 .ADDRESS XMTP4DSC ; P4 E_ADDR: .LONG 0 ; Target Address Pointer .LONG 0 ; P6 READ_IT: .LONG 12 ; No. of args .LONG 0 ; Event WETHCHN: .LONG 0 ; Channel .LONG IO$_READVBLK ; Function .LONG IOSB ; Pointer to IOSB .LONG 0 ; AST Param .LONG 0 ; AST Address .LONG RCVBUF ; P1 .LONG 1500 ; P2 .LONG 0 ; P3 .LONG 0 ; P4 .LONG RCVP5 ; RCVP5 Pointer .LONG 0 ; P6 ; ; ; Setmode param buff. IEEE requires the packet format and SAP ; to be explicitly stated. SETPARM: .WORD NMA$C_PCLI_FMT .LONG NMA$C_LINFM_802 ; IEEE packet format .WORD NMA$C_PCLI_SAP .LONG 8 ; Our SAP .WORD NMA$C_PCLI_SRV ; Service type .LONG NMA$C_LINSR_CLI ; Class 1 SETPARMLEN = .-SETPARM SETPARMDSC: .LONG SETPARMLEN .ADDRESS SETPARM ; ; P2 transmit buffer ; XMTBUF: .BYTE 00,01,02,03,04,05,06,07,08,09 .BYTE 10,11,12,13,14,15,16,17,18,19 XMTBUFLEN = .-XMTBUF ; ; P4 Transmit DSAP and CTL ; XMTP4: .BYTE 0 ; DSAP .WORD NMA$C_CTLVL_XID_P ; XID poll bit set ; XMTP4DSC: .LONG .-XMTP4 ; P4 is always 3 bytes .ADDRESS XMTP4 ; ; P2 Receive buffer ; RCVBUF: .BLKB 1500 ; ; P5 receive buffer ; RCVP5: RVCDA: .BLKB 6 RVCSA: .BLKB 6 RVCDSAP: .BLKB 1 RVCSSAP: .BLKB 1 RVCCTL : .BLKB 2 ; Misc ; .ALIGN QUAD IOSB: .QUAD 0 ; RESTIME: .LONG 0 ; Time Difference INTLTIM: .QUAD INTIM_D: .LONG 16 .ADDRESS INTIM INTIM: .ASCII /0000 00:00:02.00/ ; Max Wait for response prevprio: .long .PSECT CODE,NOWRT,EXE,LONG .CALL_ENTRY MAX_ARGS=12, HOME_ARGS=TRUE, - INPUT=, - PRESERVE=, - LABEL=LOOPX ; ; Get and Validate Params ; PROBER #0,#6,4(AP) ; Read Ethernet address? BEQL 10$ ; No CMPL #2,(AP) ; 2 params? BNEQU 20$ PROBEW #0,#4,8(AP) ; Write response time? BNEQ 20$ ; Yes 10$: MOVL #SS$_ACCVIO,R0 ; Signal error RET 20$: TSTL ETHCHN ; Init? BNEQ START ; Done - Br PUSHAL ETHCHN CALLS #1,ASSETHCHN ; Assign chan to Ethernet BSBW ERROR_CHK MOVL ETHCHN,WETHCHN ; Use same channel for RD/WRT ; ; Start up channel and set characteristics $QIOW_S FUNC=#,- CHAN=ETHCHN,- IOSB=IOSB,- P2=#SETPARMDSC BSBW ERROR_CHK MOVZWL IOSB,R0 ; Check IOSB return BSBW ERROR_CHK ; Set our priority up to mimimise effect of system load on results START: PUSHAL PREVPRIO ; Current Priority MOVL #16,-(SP) ; New prio CLRL -(SP) ; this process CLRL -(SP) ; this process CALLS #4,G^SYS$SETPRI BSBW ERROR_CHK MOVL #50,R8 ; Transmit TEST ; ROUTINE_LOOP: MOVL 4(AP),E_ADDR CMPL #2,(AP) ; Wants response time? BNEQU 10$ CLRQ RESTIME ; Init timer PUSHAL RESTIME CALLS #1,G^NTIMER ; Set start time BLBS R0,10$ RET 10$: BSBW SET_TIME ; Set time limit for test $QIOW_G WRITE_IT ; Send Loop Request BSBW ERROR_CHK ; MOVZWL IOSB,R0 ; Check IOSB return BSBW ERROR_CHK ; Queue Read 20$: $QIOW_G READ_IT ; Receive response BSBW ERROR_CHK BLBS IOSB,30$ CLRL -(SP) ; PUSHL PREVPRIO ; Previous Priority CLRL -(SP) ; this process CLRL -(SP) ; this process CALLS #4,G^SYS$SETPRI MOVL #SS$_UNREACHABLE,R0 ; ASSUME Signal Timeout RET ; Exit to caller ; Check that the response was from the target address 30$: CMPL E_ADDR,RVCSA ; BNEQ 20$ ; Not our message CMPW E_ADDR+4,RVCSA+4 BNEQ 20$ ; Not our message ; Message OK PUSHAL RESTIME ; Return start time CALLS #1,G^NTIMER ; Calc time (microseconds) BLBS R0,35$ RET 35$: ; Stop Timeout CLRL -(SP) CLRL -(SP) CALLS #2,G^SYS$CANTIM ; Stop Read timer - No error Check MOVL #SS$_NORMAL,R0 ; Signal Success on last packet CMPL #1,(AP) ; Parameter Count BEQLU EXIT ; Skip If Single loop requested 40$: MOVL RESTIME,@8(AP) ; Write reponse time EXIT: CLRL -(SP) ; PUSHL PREVPRIO ; Previous Priority CLRL -(SP) ; this process CLRL -(SP) ; this process CALLS #4,G^SYS$SETPRI BSBW ERROR_CHK MOVL #SS$_NORMAL,R0 ; Signal Success RET ; Exit to caller ; Here on Read Timout ; .CALL_ENTRY MAX_ARGS=12, HOME_ARGS=TRUE, - INPUT=, - PRESERVE=, - LABEL=LOOPX_LOST_MSG PUSHL ETHCHN CALLS #1,G^SYS$CANCEL ; Cancel I/O - No error check RET ; Exit to main ; Subroutines ; ; ; Routine Error ERROR_CHK: .JSB_ENTRY INPUT=, - OUTPUT= BLBC R0,10$ RSB 10$: MOVL R0,R7 ; Save Error $DASSGN_S CHAN=ETHCHN ; No error Check CLRL ETHCHN TSTL PREVPRIO ; Have we reset prio? BEQLU 20$ ; No - skip CLRL -(SP) ; PUSHL PREVPRIO ; Previous Priority CLRL -(SP) ; this process CLRL -(SP) ; this process CALLS #4,G^SYS$SETPRI 20$: MOVL R7,R0 ; Restore error RET SET_TIME: .JSB_ENTRY INPUT=, - OUTPUT= ; Set the timeout for read ; ; ; Set the timer ; Convert the input time - must be DELTA ; $BINTIM_S- TIMBUF=INTIM_D,- TIMADR=INTLTIM ; $SETIMR_S- DAYTIM=INTLTIM,- ASTADR=LOOPX_LOST_MSG ; AST address RSB .END