.TITLE EXAMPLE LAN SAMPLE TEST PROGRAM .IDENT /X01/ ; This LAN test program will send a LOOPBACK message to another system ; and wait for a response. Since LOOPBACK forwarding is handled by the ; controller or the driver at the other node, you should always get a ; response as long as the other node exists. ; ; Note that this test will try to use the device defined by the logical ; LAN as the LAN device. If this does not work, then it will try to use ; one of the currently known LAN devices. To use a particular Ethernet ; or FDDI device, you need to define the logical LAN to be the name of the ; device you wish t use. For example: ; ; $ DEFINE LAN EXB0 ; ; Note that if you have service enabled on a DECnet circuit enabled on the ; controller you wish to test, this program will get a fatal error ; when trying to start its port. This is expected because DECnet will ; start its own port for the LOOPBACK protocol. .LIBRARY "SYS$LIBRARY:LIB.MLB" $IODEF ; Define I/O functions and modifiers $NMADEF ; Define Network Management parameters ; Local definitions RCVBUFLEN = 512 ; Size of receive buffer XMTBUFLEN = 20 ; Size of transmit buffer ; Setmode parameter buffer. You are required to state only the ; unique protocol type value. However, you will also state the packet format. ; Since the LOOPBACK protocol does not include a LENGTH word following the ; protocol type, you have to explicitly turn OFF padding since the default is ; ON. SETPARM: .WORD NMA$C_PCLI_FMT ; Packet format .LONG NMA$C_LINFM_ETH .WORD NMA$C_PCLI_PTY ; Our Protocol type .LONG ^X0090 .WORD NMA$C_PCLI_PAD ; Padding .LONG NMA$C_STATE_OFF SETPARMLEN = .-SETPARM SETPARMDSC: .LONG SETPARMLEN .ADDRESS SETPARM ; Sensemode parameter buffer. This will be used to get our node's physical ; address to put into the loopback message. SENSEBUF: .BLKB 250 SENSELEN=.-SENSEBUF SENSEDSC: .LONG SENSELEN .ADDRESS SENSEBUF ; P2 transmit data buffer XMTBUF: .WORD 00 ; Skip count .WORD 02 ; Forward request FORW: .BLKB 6 ; You will put our address here .WORD 01 ; Reply request .WORD 00 XMTBUFLEN = .-XMTBUF ; P5 transmit destination address ; ; Set this value to be a node on your LAN that supports LOOPBACK. XMTP5: .BYTE ^XAA,^X00,^X04,^X00,^X17,^X4E ; P2 receive data buffer RCVBUF: .BLKB RCVBUFLEN ; P5 receive header buffer RCVP5: RCVDA: .BLKB 6 RCVSA: .BLKB 6 RCVPTY: .BLKB 2 ; Messages used to display status of this program. GMSG: .ASCID "Successful test" BMSG: .ASCID "Received packet was not what was expected" LMSG: .ASCID "Packet lost or node not responding" EMSG: .ASCID "Error occurred while running test" DMSG: .ASCID "No LAN device found - please define LAN correctly" ; Miscellaneous data structures TRY: .WORD 0 ; Number of times you have tried ; the READ QIO (start at 0) IOSB: .BLKQ 1 ; I/O status block LANDSC1:.ASCID 'LAN' ; Units to use for test LANDSC2:.ASCID 'ECA0' LANDSC3:.ASCID 'ESA0' LANDSC4:.ASCID 'ETA0' LANDSC5:.ASCID 'EXA0' LANDSC6:.ASCID 'EZA0' LANDSC7:.ASCID 'FCA0' LANDSC8:.ASCID 'FXA0' LANDSC9:.ASCID 'XEA0' LANDSCA:.ASCID 'XQA0' DSCADR: .ADDRESS LANDSC1 ; Table of addresses pointing to .ADDRESS LANDSC2 ; the descriptors of device names .ADDRESS LANDSC3 .ADDRESS LANDSC4 .ADDRESS LANDSC5 .ADDRESS LANDSC6 .ADDRESS LANDSC7 .ADDRESS LANDSC8 .ADDRESS LANDSC9 .ADDRESS LANDSCA .LONG 0 DEVCHAN:.BLKL 1 ; Returned port number ;************************************************************************* ; ; Start of code ; ;************************************************************************* .ENTRY START,^M<> ; Assign a port to the LAN device. If LAN does not work, try each ; of the currently known LAN devices. ASSIGN: MOVAL DSCADR,R5 ; Start at beginning 10$: MOVL (R5),R4 ; Is there a descriptor? BEQL 20$ ; If EQL, no $ASSIGN_S DEVNAM=(R4),CHAN=DEVCHAN BLBS R0,ASSIGN_OK ADDL #4,R5 ; Skip to next descriptor CMPW R0,#SS$_NOSUCHDEV ; Was the device not there? BEQL 10$ ; If EQL, yes, try next device BRW ERROR ; You could not find a LAN device to assign a port to. 20$: PUSHAB DMSG BRW EXIT ASSIGN_OK: ; Set up the port's characteristics. $QIOW_S FUNC=#,- CHAN=DEVCHAN,IOSB=IOSB,- P2=#SETPARMDSC BLBS R0,STARTUP_REQ_OK BRW ERROR STARTUP_REQ_OK: MOVZWL IOSB,R0 BLBS R0,STARTUP_IO_OK BRW ERROR STARTUP_IO_OK: ; Now issue the SENSEMODE QIO so that you can get our physical address and ; put it in the LOOPBACK message you are about to transmit. $QIOW_S FUNC=#,- CHAN=DEVCHAN,IOSB=IOSB,- P2=#SENSEDSC BLBS R0,SENSE_REQ_OK BRW ERROR SENSE_REQ_OK: MOVZWL IOSB,R0 BLBS R0,SENSE_IO_OK BRW ERROR SENSE_IO_OK: ; Now you have to locate the PHA parameter in the SENSEMODE buffer and copy ; it into our LOOPBACK transmit message. You will scan the return buffer ; for a string parameter. If you find a string parameter, you will check if ; it's the PHA parameter. MOVAB SENSEBUF,R0 ; Start at beginning of buffer 10$: BBS #^XC,(R0),20$ ; If this is a string parameter, ; goto 20$ ; Skip over the longword parameter. ADDL #6,R0 ; Skip 2-byte type and 4-byte value BRB 10$ ; Check next parameter ; This is a string parameter. Check if it's the PHA parameter. 20$: BICW #^XF000,(R0) ; Clear flag bits in type field CMPW #NMA$C_PCLI_PHA,(R0) ; Is this the PHA parameter? BEQL 30$ ; If EQL, yes ; Skip over this string parameter. ADDL #2,R0 ; Skip 2-byte type MOVZWL (R0)+,R1 ; Convert string size to longword ; and skip it ADDL R1,R0 ; Skip string BRB 10$ ; Check next parameter ; You have located the PHA parameter. Move it into the LOOPBACK transmit ; buffer. 30$: MOVL 4(R0),FORW ; Move 1st four bytes MOVW 8(R0),FORW+4 ; Move last two bytes ; Now transmit our TEST message. $QIOW_S FUNC=#IO$_WRITEVBLK,CHAN=DEVCHAN,IOSB=IOSB,- P1=XMTBUF,P2=#XMTBUFLEN,P5=#XMTP5 BLBS R0,XMIT_REQ_OK BRW ERROR XMIT_REQ_OK: MOVZWL IOSB,R0 BLBS R0,XMIT_IO_OK BRW ERROR XMIT_IO_OK: ; Now try to receive the response. You will use the NOW function modifier ; on the READ so that you don't hang here waiting forever if there is no ; response. You will attempt to receive the message 1000 times. If there ; is no response by then, you will declare the response lost. RECV: $QIOW_S FUNC=#IO$_READVBLK!IO$M_NOW,CHAN=DEVCHAN,IOSB=IOSB,- P1=RCVBUF,P2=#RCVBUFLEN,P5=#RCVP5 BLBS R0,RECV_REQ_OK BRW ERROR RECV_REQ_OK: MOVZWL IOSB,R0 BLBS R0,RECV_IO_OK CMPW R0,#SS$_ENDOFFILE ; Was there just no message available? BEQL 10$ ; Branch if so to try again BRW ERROR ; If you are able to post 1000 reads and not receive the response packet, then ; you will assume the packet is lost. 10$: CMPW TRY,#1000 ; Have you tried enough? BGTR LOST ; If GTR, yes, so message is lost INCW TRY ; Try again BRB RECV RECV_IO_OK: ; You received a message. Check that the Source Address matches the place we ; sent the message. CMPL XMTP5,RCVSA BNEQ RECV_BAD CMPW XMTP5+4,RCVSA+4 BEQL RECV_OK ; There was something wrong with the message received. RECV_BAD: PUSHAB BMSG BRB EXIT ; The test went fine. Print a success message. RECV_OK: PUSHAB GMSG BRB EXIT ; You lost the message. Print a message stating so. LOST: PUSHAB LMSG BRB EXIT ; There was an error while running the test. Print a message stating so. ERROR: PUSHAB EMSG BRB EXIT ; The test is done. You will call LIB$PUT_OUTPUT to display the status of ; this test. The message that will be displayed has its descriptor on the ; stack. That descriptor will be used by the LIB$PUT_OUTPUT routine. EXIT: CALLS #1,G^LIB$PUT_OUTPUT $EXIT_S .END START