Detecting an Econet bridge

 

 

There are two calls you can send to a bridge.

1. What is our 'local' network?

$buffer%  = "Bridge"
buffer%?6 = reply_port%
buffer%?7 = 0

This, sent to the bridge's port &82, will cause the bridge to reply with two bytes. The first byte will be the local network number, the second byte will be the software running in the bridge.

2. What networks are known about?

$buffer%  = "Bridge"
buffer%?6 = reply_port%
buffer%?7 = network_to_check%

Sent to port &83 of the bridge, 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 that network would respond.

 

 

The following program shows this in practice.

REM >checknets
REM
REM Checks our local network, and looks to see what others are available.
REM Copyright © 1999 Richard Murray
REM
REM This version is for RiscOS machines ONLY.
REM
:
checknet% = 0
DIM txcb% 32
DIM rxcb% 32

REM STEP ONE:
REM   Ascertain our 'local' network.

port% = FNallocateport

$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%
:


Return to econet index


Copyright © 1999 Richard Murray