EthernetDriverStatsImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Major rewrite of old EthernetOneDriver, HGM, Jan 86
Hal Murray, February 4, 1986 3:45:47 am PST
DIRECTORY
Driver USING [GetNetworkChain, Network, Type],
EthernetDriverStats USING [EtherStats];
EthernetDriverStatsImpl: CEDAR PROGRAM
IMPORTS Driver
EXPORTS EthernetDriverStats = {
Network: TYPE = Driver.Network;
GetEthernetConfig: PUBLIC PROC RETURNS [instances: NAT ← 0] = {
Returns how many instances are present for the Xerox research Ethernet (3Mbit).
FOR network: Network ← Driver.GetNetworkChain[], network.next UNTIL network = NIL DO
IF network.type = ethernet THEN instances ← instances + 1;
ENDLOOP;
};
GetEthernetOneConfig: PUBLIC PROC RETURNS [instances: NAT ← 0] = {
Returns how many instances are present for the Xerox research Ethernet (3Mbit).
FOR network: Network ← Driver.GetNetworkChain[], network.next UNTIL network = NIL DO
IF network.type = ethernetOne THEN instances ← instances + 1;
ENDLOOP;
};
GetEthernetStats: PUBLIC PROC [instance: NAT] RETURNS [stats: EthernetDriverStats.EtherStats ← NIL] = {
... returns the EtherStats object for the given instance of the Xerox research Ethernet driver. Note that these numbers are not monitor protected, so be prepared for strange results every so often. NIL will be returned for invalid instances.
network: Network ← GetNthDeviceLikeMe[ethernet, instance];
IF network # NIL THEN stats ← NARROW[network.stats];
};
GetEthernetOneStats: PUBLIC PROC [instance: NAT] RETURNS [stats: EthernetDriverStats.EtherStats ← NIL] = {
... returns the EtherStats object for the given instance of the Xerox research Ethernet driver. Note that these numbers are not monitor protected, so be prepared for strange results every so often. NIL will be returned for invalid instances.
network: Network ← GetNthDeviceLikeMe[ethernetOne, instance];
IF network # NIL THEN stats ← NARROW[network.stats];
};
GetNthDeviceLikeMe: PROC [type: Driver.Type, physicalOrder: NAT] RETURNS [Network] = {
i: NAT ← 0;
FOR network: Network ← Driver.GetNetworkChain[], network.next UNTIL network = NIL DO
IF network.type = type THEN {
IF i = physicalOrder THEN RETURN[network];
i ← i + 1; }
ENDLOOP;
RETURN[NIL];
};
}.