Important: The information in this document is obsolete and should not be used for new development.
Using the Token Ring Driver
You can write an application implementing a protocol other than AppleTalk that reads data from and writes it to the token ring driver defined by Apple.To write data to the token ring driver and to perform other functions such as adding a functional address for the token ring hardware, you use the Ethernet functions described earlier, with the modifications noted later in this section. To read 802.2 packets from the token ring driver, you need to attach your protocol handler to the LAP Manager.
The Apple token ring driver implementation supports only the IEEE 802.2 Type 1 protocol and allows for the attachment of only one protocol handler that reads
802.2 packets that contain an SAP value of $AA.Although it is possible to attach your own protocol handler at the hardware device driver level, Apple recommends that you not do this because it excludes AppleTalk from using the token ring driver. So that more than one protocol can receive packets from the token ring driver concurrently, Apple recommends that you attach your protocol handler to the LAP Manager. The LAP Manager attaches its own protocol handler to the token ring driver, and when it receives a packet for your protocol, the LAP Manager calls your protocol handler. When it receives a packet for another protocol, such as AppleTalk, the LAP Manager calls that application's protocol handler.
For a description of how to attach and detach your protocol handler for token ring, see the chapter "Link-Access Protocol (LAP) Manager" included in this book and the discussion of token ring and FDDI in "About Ethernet, Token Ring, and FDDI Support" beginning on page 11-3 in this chapter. The chapter "Link-Access Protocol (LAP) Manager" also gives more information on the SAP field value for 802.2 Type 1 packets.
Applying Ethernet Functions
The Apple token ring driver implements many but not all of the functions that the Apple Ethernet driver implements.For those Ethernet functions that do apply to token ring, you use the function for token ring in the same way that you do for Ethernet: you pass parameters in a parameter block and you use the Ethernet control code in the
csCode
field to call the function. The only difference is that instead of specifying the Ethernet driver reference number in the parameter block'sioRefNum
field, you specify the token ring driver reference number. Here are the Ethernet functions that apply to token ring:
Here are the Ethernet functions that do not apply to token ring:
- You use the
EAddMulti
function to add a functional address for token ring and theEDelMulti
function to remove one. Be careful not to specify the broadcast address
as a functional address. See Inside AppleTalk, second edition, for a description and the format of functional and broadcast addresses for token ring.- You use the
EWrite
function to send data to the token ring driver for transmission over the network.
There are some other differences between Ethernet and token ring:
- The
ERead
andERdCancel
functions are not valid for token ring because Apple does not specify a default protocol handler for the token ring driver. These two functions are used exclusively by applications that use the default Ethernet protocol handler. If an application calls these functions for token ring, the driver will return an error.- The
ESetGeneral
function switches to a mode that allows the .ENET driver to transmit a larger Ethernet data packet than the standard size. Because token ring is not normally restricted to the limited packet size, this function does not apply. However, the token ring driver will return a result ofnoErr
if you call this function.
- The token ring packet size is determined by the token ring hardware developer. However, for Logical Link Control (LLC) type packets, the packet length cannot exceed 1500 bytes.
- The token ring interface uses functional addresses instead of multicast addresses. Be careful not to use the broadcast address for a functional address. For information about both kinds of token ring addresses, see Inside AppleTalk, second edition.
- For token ring, the vendor who supplies the hardware device driver provides a control panel that allows you to specify an alternative hardware address. (For general information about alternative hardware addresses, see "Changing the Ethernet Hardware Address" on page 11-19.)
- Note
- Although you can use the
EAttachPH
function to attach a protocol handler to the token ring driver and theEDetachPH
function to
remove one, Apple recommends that you not use these functions. Instead, you should use the LAP Manager'sL802Attach
andL802Detach
routines.Sending and Receiving Data
The tasks involved in sending data to and receiving it from a token ring driver are similar to those that you use for Ethernet. The primary difference is that you use the LAP Manager to attach your protocol handler. Any vendor implementing a token ring driver to run on a Macintosh computer must follow rules that direct them to return packet information in the same manner as does the Ethernet driver for 802.2 packets. From the perspective of an application that uses the token ring driver, this means that when the LAP Manager calls your protocol handler, you can expect the token ring hardware addresses that you reference from register A3 to follow the same format that is used for Ethernet addresses, regardless of how the token ring address might appear at the hardware level.Here are the steps that you follow to send data to and receive it from a token ring driver:
- Locate the token ring cards that are installed in the system. Use the Slot Manager to identify installed token ring cards. Use the
SGetTypeSRsrc
function described in the Slot Manager chapter of Inside Macintosh: Devices to determine which NuBus slots contain token ring cards. To find token ring cards, use the valuecatNetwork
(0x4)
in thespCategory
field and the valuetypeTokenRing
(0x2)
in thespCType
field. You should provide a user interface that allows the user to select a specific token ring card in the case that more than one is present.- Use the
OpenSlot
function to open the token ring driver. Set theioNamePtr
field to .TOKN. If you did not locate any NuBus token ring cards in step 1, you should also attempt to open the .TOKN0 driver in case non-NuBus token ring hardware is attached to the system. Use the Device Manager'sOpenDriver
function to open the .TOKN0 driver. (For information on theOpenSlot
andOpenDriver
functions, see the chapter "Device Manager" in Inside Macintosh: Devices.)Note that this section refers to the .TOKN driver shell, which facilitates multi-
vendor support, as the .TOKN driver. Opening the .TOKN driver shell, which
loads and opens the card's driver, is effectively the same as directly opening the
token ring driver.- If your application requires a functional address, use the
EAddMulti
function to register one. Functional addresses are the token ring equivalent of Ethernet and FDDI multicast addresses. (For information on functional addresses, see Inside AppleTalk, second edition. For a description of multicast addresses, see "About Multicast Addressing" on page 11-7.)- Use the LAP Manager's
L802Attach
routine to install your protocol handler. (See the chapter "Link-Access Protocol [LAP] Manager" in this book for more information.)- Use the
EWrite
function to send packets to the token ring driver for transmission across the network. To use theEWrite
function, you provide a pointer to a write-data structure. The first buffer in the write-data structure must be at least 14 bytes long: the first 6 bytes of that buffer must contain the destination address. Bytes 13 and 14 must contain the packet length, which must not exceed 1500 bytes. The token ring driver fills in bytes 7-12 with the source address. (For more information on the write-data structure, see "Using a Write-Data Structure to Transmit Ethernet Data" on page 11-10.)- When you are finished using the token ring driver, use the LAP Manager's
L802Detach
routine to remove your protocol handler.- When you are finished using a functional address, use the
EDelMulti
function to remove it.