EEA index
Bridges
Intro |
PrécisThere is little reason to engage in this, unless you wish to manually probe the network, for the NetFS/ANFS automatically handles detection of file servers across bridged networks; and to this end it may be much more productive to issue the SWI NetFS_EnumerateFSList (SWI &40049), perhaps after having issued the SWI NetFS_UpdateFSList (&4004D) with both R0 and R1 set to zero to cause the entire list of known servers to be updated.Don't forget to call SWI NetFS_EnableCache (&40051) afterwards to allow automatic caching of known servers to resume.
With little more than three calls and a FOR...NEXT loop, you can ascertain which file servers (by name and disc number) are available at which stations on which networks.
Communicating with the bridgeThere are two calls you can send to a bridge.1. What is our 'local' network?
$buffer% = "Bridge" buffer%?6 = reply_port% buffer%?7 = 0 You should broadcast control byte &82 to port &9C. If any bridge is present, it will reply with two bytes. The first byte will be the local network number, the second byte will be the software running in the bridge. $buffer% = "Bridge" buffer%?6 = reply_port% buffer%?7 = network_to_check%
You should broadcast control byte &83 to port &9C. If any bridge is present, the bridge will perform a four-way handshake if the network number is known to it, otherwise it will not reply. Only the bridge which would handle the network specified will respond.
Putting this into practiceThe following program shows how to communicate with a bridge.REM >checknets REM REM Checks our local network, and looks to see what REM others are available. REM © 2007 Rick Murray [original from 1999] REM REM This version is for RISC OS machines ONLY. REM : checknet% = 0 DIM txcb% 32 DIM rxcb% 32 REM STEP ONE: REM Ascertain our 'local' network. handle% = 0 port% = FNallocateport : REM Also sets 'handle%' $txcb% = "Bridge" txcb%?6 = port% txcb%?7 = 0 SYS "Econet_DoTransmit", &82, &9C, &FF, &FF, txcb%, 8, 2, 3 SYS "Econet_WaitForReception", handle%, 8, 0 TO status% IF status% = 9 THEN PRINT "Our local network is network "+STR$(rxcb%?0); PRINT ", bridge software version "+STR$(rxcb%?1)+"." ENDIF SYS "Econet_DeAllocatePort", port% REM STEP TWO: REM Look for other networks. REPEAT checknet% += 1 PRINT "Checking for network "+STR$(checknet%)+"..."+CHR$(13); port% = FNallocateport $txcb% = "Bridge" txcb%?6 = port% txcb%?7 = checknet% SYS "Econet_DoTransmit", &83, &9C, &FF, &FF, txcb%, 8, 2, 3 SYS "Econet_WaitForReception", handle%, 8, 0 TO status% IF status% = 9 THEN PRINT "Network "+STR$(checknet%)+" exists. " ENDIF SYS "Econet_DeAllocatePort", port% UNTIL checknet% = 127 PRINT STRING$(30, " ")' END : : DEFFNallocateport SYS "Econet_AllocatePort" TO port% IF port% = &9C THEN REM Defeat local loopback... SYS "Econet_DeAllocatePort", port% SYS "Econet_AllocatePort" TO port% ENDIF SYS "Econet_CreateReceive", port%, 0, 0, rxcb%, 10 TO handle% =port%
And for 8 bit machines...The following program was OCRed and tidied from the MDFS manual, section 10, pages 45-46. It is reproduced here to save you needing to download a 17½Mb archive containing numerous large PDF files - not a viable proposition for those using dial-up access.Please note that this program may contain errors due to the OCR. I have corrected any that I have found, but some may remain. It's a lot better than the garbled listing in my printed MDFS manual, which misses a big chunk in the middle!
10 REM Find out what other networks are available 20 REM (C) 1986, A.J.Engeham, SJ Research 30 REM ____________________________________________ 40 50 DIM blk% 100, tx_blk% 20, buffer% 100 60 70 osword=&FFF1:osbyte=&FFF4 80 reply_port=&8A:retries=l0 90 PROCset_up_rx 100 110 FOR bridge%=l TO 127 120 FOR dummy%=l TO 3 130 PROCbroadcast(bridge%) 140 NEXT 150 160 dummy%=0 170 REPEAT 180 dummy%=dummy%+l 190 UNTIL dummy%=retries OR FNpoll_rx 200 210 IF FNpoll_rx THEN PROCdisplay(bridge%) 220 NEXT 230 PROCdelete 240 PRINT "Finished" 250 END 260 270 DEFPROCset up rx 280 blk%?0=0 : REM control block number put here 290 blk%?1=&7F 300 blk%?2=reply_port 310 blk%!3=&0 : REM Receive from any stations 320 blk%!5=buffer% 330 blk%!9=buffer%+8 340 X%=blk% : Y%=blk% DIV 256 350 A%=&ll 360 CALL osword 370 IF blk%?0=0 THEN PRINT "Can't open a Rx block" : END 380 ENDPROC 390 400 DEFFNpoll_rx 410 A%=&33 420 X%=blk%?0 : REM Get the rx block number 430 =((USR osbyte) AND &8000) <> O 440 450 DEFPROCbroadcast(network%) 460 LOCAL redo 470 redo=5 480 490 REPEAT 500 tx_blk%?0=&83 510 tx_blk%?1=&9C : REM Broadcast on port &9C 520 tx_blk%!2=&FFFF: REM Broadcast operation 530 $(tx_blk%+4)="BRIDGE" 540 tx_blk%?10=reply_port 550 tx_blk%?11=network% 560 X%=tx_blk% : Y%=tx_blk% DIV 256 570 A%=&10 : CALL osword 580 A%=&32 590 REM Wait for completion 600 X%=FNpoll_tx 610 redo=redo-l 620 UNTIL redo=0 OR X%=&40 OR X%=&43 OR X%=&44 OR X%=0 630 IF X%>0 THENPRINT"Broadcast fail, error &";~X%:PROCdelete:END 640 ENDPROC 650 660 DEFPROCdelete 670 REM delete a receive block 680 A%=&34 690 X%=blk%?0 700 CALL osbyte 710 ENDPROC 720 730 DEFFNpoll_tx 740 REPEAT UNTIL NOT {(USR osbyte) AND &8000) 750 =(((USRosbyte) AND &FF00) DIV &100) 760 770 DEFPROCdisplay(no%) 780 PRINT "Found network "; no% 790 PROCdelete 800 PROCset_up_rx 810 ENDPROC |