home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
lan
/
lanstat
/
lanstat.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1989-09-18
|
5KB
|
203 lines
{=======================================================================}
{ LANSTAT Display the results of an Adapter Status NetBIOS call }
{ }
{ lanstat Display status of local adapter }
{ lanstat [-p] nodename Display status of named adapter }
{ lanstat -? Display a usage message }
{ }
{ Issue the NetBIOS Adapter Status command, and print the values of the }
{ various fields. This command can display the status of both local }
{ and remote adapters. }
{ }
{ An Artisoft Lantastic network is assumed, only to the extent that the }
{ adapter status is assumed to be in the PC Network LANA format, and }
{ not the Token-Ring format, and that certain of the reserved area }
{ fields are assumed to hold specific information as defined in }
{ Artisoft documentation. }
{ }
{ By default, Lanstat will return the status for the local adapter. A }
{ particular node name may be used, in which case Lanstat will return }
{ the status for a (possibly) remote adapter. If the -p option is }
{ given, then upper/lower case distinctions in the node name are }
{ preserved, otherwise the node name is forced to upper case. }
{=======================================================================}
program LanStat;
uses DOS, NetBios;
var
ErrCode : byte;
NodeName : NetName;
StatusNcb : Ncb;
Status : LanaStatus;
function EditArgs : boolean;
var
Node : string;
OK : boolean;
PFlag : boolean;
I : word;
begin
OK := FALSE;
PFlag := FALSE;
case ParamCount of
0 : begin
OK := TRUE;
Node := '*';
end;
1 : if (ParamStr(1) <> '-p') and (ParamStr(1) <> '-P') and
(ParamStr(1) <> '-?') then begin
OK := TRUE;
Node := ParamStr(1);
end;
2 : if (ParamStr(1) = '-p') or (ParamStr(1) = '-P') then begin
OK := TRUE;
PFlag := TRUE;
Node := ParamStr(2);
end;
end;
if not OK then begin
writeln('Usage: "LanStat [[-p] NodeName]" or "LanStat -?"');
writeln('Display the status of a LAN adapter');
EditArgs := FALSE;
exit;
end;
if Length(Node) > 16 then begin
writeln('NodeName too long - should be 1 to 16 characters');
EditArgs := FALSE;
exit;
end;
FillChar(NodeName, 16, ' ');
for I := 1 to Length(Node) do
if PFlag then
NodeName[I] := Node[I]
else
NodeName[I] := UpCase(Node[I]);
EditArgs := TRUE;
end;
function RequestStatus : byte;
begin
ClearNcb(StatusNcb);
with StatusNcb do begin
Buffer := @Status;
Command := NBAdapterStatus;
Length := Sizeof(Status);
RemName := NodeName;
end;
CallNetBIOS(StatusNCB);
RequestStatus := StatusNCB.RetCode;
end;
procedure Display1Hex(X : byte);
const
HexDigits : string[16] = '0123456789ABCDEF';
begin
write(HexDigits[(X and $0F)+1]);
end;
procedure Display2Hex(X : byte);
begin
Display1Hex(X shr 4);
Display1Hex(X);
end;
procedure DisplayNetName(Name : NetName);
var
I : word;
C : char;
Graphic : boolean;
begin
Graphic := FALSE;
for I := 1 to 16 do begin
C := Name[I];
if (C >= chr($20)) and (C <= chr($7E)) then begin
if NOT Graphic then begin
Graphic := TRUE;
write('"');
end;
write(C);
end else begin
if Graphic then begin
Graphic := FALSE;
write('"');
end;
if I <> 1 then
write('.');
Display2Hex(ord(C));
end;
end;
if Graphic then
write('"');
end;
procedure DisplayStatus;
var
I : word;
begin
with Status do begin
write('Adapter Status of ');
DisplayNetName(NodeName);
writeln;
write('NetBIOS V', SoftwareVersionMajor, '.', SoftwareVersionMinor,
' NodeName=');
for I := 1 to 6 do begin
Display2Hex(PermanentNodeName[I]);
if I <> 6 then
write('.');
end;
writeln(' Active for ',ReportingPeriodMinutes,' minutes');
write('Misc: Jumpers(');
Display2Hex(ExternalJumperSetting);
write('), SelfTest(');
Display2Hex(SelfTestResults);
writeln('), MaxPacketSize(',MaximumPacketSize,')');
{ The extended fields are specific to Artisoft Lantastic }
writeln('Extended: BufUsed(',ReservedArea2[0],
'), MaxBuf(',ReservedArea2[1],
'), NoBuf(',ReservedArea1[0],
'), StolenBuf(',ReservedArea1[1],')');
writeln('Usage: GoodXmits(',SuccessfulXmits,
'), GoodRcvs(',SuccessfulRcvs,
'), ReXmit(',RetransmitCount,
'), Depletion(',ResourceDepletionCount,')');
writeln('Errors: Crc(',CrcErrorCount,
'), Alignment(',AlignmentErrors,
'), Collision(',CollisionCount,
'), XmitAbort(',XmitAbortCount,')');
writeln('NCBs: Free(',FreeCommandBlocks,
'), Max(',CurrentMaxNcbs,
'), HardwareMax(',HwMaxCommandBlocks,')');
writeln('Sessions: Pending(',PendingSessionCount,
'), Max(',CurrentMaxSessions,
'), HardwareMax(',HwMaxSessionCount,')');
writeln('Names: Entries(',NameTableEntryCount,')');
for I := 1 to NameTableEntryCount do begin
write(' #',TableEntry[I].Num,', Status(');
Display2Hex(TableEntry[I].Status);
write('), ');
DisplayNetName(TableEntry[I].Name);
writeln;
end;
end;
end;
begin
if NOT EditArgs then
exit;
ErrCode := RequestStatus;
if ErrCode <> 0 then
writeln('Request status error ',ErrCode)
else
DisplayStatus;
end.