.TITLE EXAMPLE 802 SAMPLE TEST PROGRAM .IDENT /X01/ ; This 802 test program will send a TEST message to another system and ; wait for a response. Since you will be sending the message to the ; MAC Sublayer on 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 .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. For 802, you are required to state the packet ; format and our unique SAP value. SETPARM: .WORD NMA$C_PCLI_FMT ; Packet format .LONG NMA$C_LINFM_802 .WORD NMA$C_PCLI_SAP ; Our individual SAP address .LONG 2 SETPARMLEN = .-SETPARM SETPARMDSC: .LONG SETPARMLEN .ADDRESS SETPARM ; P2 transmit data buffer XMTBUF: .BYTE 00,01,02,03,04,05,06,07,08,09 .BYTE 10,11,12,13,14,15,16,17,18,19 ; P4 transmit DSAP and CTL field values XMTP4: .BYTE 0 ; DSAP for transmit is the MAC ; Sublayer SAP (zero) .WORD NMA$C_CTLVL_TEST ; The CTL field value is TEST ; P4 transmit descriptor XMTP4DSC: .LONG 3 ; P4 is always 3 bytes in size .ADDRESS XMTP4 ; Address of buffer ; P5 transmit destination address ; ; Set this value to be a node on your LAN that supports 802 packet ; format. 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 RCVDSAP:.BLKB 1 RCVSSAP:.BLKB 1 RCVCTL: .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 transmit our TEST message. $QIOW_S FUNC=#IO$_WRITEVBLK,CHAN=DEVCHAN,IOSB=IOSB,- P1=XMTBUF,P2=#XMTBUFLEN,P4=#XMTP4DSC,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 IO$M_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 BNEQ RECV_BAD ; Check that the data received was the correct size. CMPW #XMTBUFLEN,IOSB+2 BNEQ RECV_BAD ; Check that the data received matches the data you sent. MOVZBL #XMTBUFLEN,R0 MOVAB XMTBUF,R1 MOVAB RCVBUF,R2 10$: CMPB (R1)+,(R2)+ BNEQ RECV_BAD SOBGTR R0,10$ BRB RECV_OK ; All bytes matched ; 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