home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
pingdg.exe
/
PING.C
next >
Wrap
C/C++ Source or Header
|
1995-03-29
|
4KB
|
137 lines
/*****************************************************************
DISCLAIMER
Novell, Inc. makes no representations or warranties with respect to
any NetWare software, and specifically disclaims any express or
implied warranties of merchantability, title, or fitness for a
particular purpose.
Distribution of any NetWare software is forbidden without the
express written consent of Novell, Inc. Further, Novell reserves
the right to discontinue distribution of any NetWare software.
Novell is not responsible for lost profits or revenue, loss of use
of the software, loss of data, costs of re-creating lost data, the
cost of any substitute equipment or program, or claims by any party
other than you. Novell strongly recommends a backup be made before
any software is installed. Technical support for this software
may be provided at the discretion of Novell.
*****************************************************************/
/*
PROG: ping.c
LANG: Borland C++ v3.1
SDK: NetWare Client SDK v1.0e
NAME: Jack Gumaer
DATE: 29-MAR-1995
VER: 1.0
Revision History: N/A
Description: This sample program queries a particular node
using the NetWare Diagnostic Services APIs and returns the
version of IPX, SPX, and NETX loaded on that node.
Usage: ping network address : node address
Example: ping 12341234:112233445566
*/
#include <stdio.h>
#include <diag.h> /* NetWare Client SDK diagnostics header file */
main(int argc,char *argv[])
{ char i,string[21],string2[2];
int j,result,offset,x;
WORD connID;
BYTE componentList[54];
BeginDiagnosticStruct iPXAddress; /* Same as IPXAddress */
static AllResponseData ard;
static ShellVersionStruct svs;
static IPXSPXVersion ipxver;
printf("\nPING Sample Code v1.0 29-MAR-1995");
if(argc != 2) /* invalid parameters */
{ printf("\n\nUsage: ping network:node");
printf("\nFor example: ping 12341234:0a1b2c3d4e5f\n");
exit();
}
/*** Process address parameters ***/
strcpy(string,argv[1]);
for(j=0;j<21;j++) /* check for valid data */
{ string[j] = toupper(string[j]); /* convert to uppercase */
if((string[j] >47) && (string[j] < 58)) /* it is a number */
{ string[j] = string[j] - 48;
}
else
{ if((string[j] > 64) && (string[j] < 71)) /* letters A-F */
{ string[j] = string[j] - 55;
}
else
{ if((j==8) && (string[8] == ':')) /* check for : */
{ /* do nothing here */
}
else
{ printf("\nError: Invalid data character %d",j+1);
exit();
}
}
}
}
/* convert network address */
for(j=0;j<4;j++)
{ iPXAddress.network[j] = ((string[j*2]*16)+string[j*2+1]);
}
/* convert node address */
for(j=0;j<6;j++)
{ iPXAddress.node[j] = ((string[(j*2)+9]*16)+string[(j*2)+10]);
}
/*** Begin Diags ***/
result = IPXInitialize();
if(result != 0) /* IPXInitialize() failed */
{ printf("\nError: IPXInitialize() failed; return code = %X\n",
result);
exit();
}
result = BeginDiagnostics(&iPXAddress,&connID,componentList);
if(result != 0) /* BeginDiagnostics() failed */
{ printf("\nError: BeginDiagnostics() failed; return code = %X\n",
result);
exit();
}
/*** Get IPX/SPX component offset ***/
offset = FindComponentOffset(componentList,0);
/*** Get and display IPX/SPX version ***/
result = GetIPXSPXVersion(connID,(BYTE) offset,&ard,&ipxver);
if(ard.completionCode == 0)
{ printf("\nIPX Version: %d.%d",
ipxver.IPXMajorVersion,ipxver.IPXMinorVersion);
printf("\nSPX Version: %d.%d",
ipxver.SPXMajorVersion,ipxver.SPXMinorVersion);
}
else
{ printf("\nError getting IPX/SPX version: %d",
ard.completionCode);
}
/*** Get NETX shell component offset ***/
offset = FindComponentOffset(componentList,3);
/*** Display shell version ***/
result = GetShellVersionInfo(connID,(BYTE) offset,&ard,&svs);
if(ard.completionCode == 0)
{ printf("\nShell version: %d.%d",svs.major,svs.minor);
}
else
{ printf("\nError getting shell version: %d",ard.completionCode);
}
EndDiagnostics(connID);
printf("\nEndDiagnostics() return code = %x\n",result);
}