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 >
C/C++ Source or Header  |  1995-03-29  |  4KB  |  137 lines

  1. /*****************************************************************
  2.             DISCLAIMER
  3.  
  4. Novell, Inc. makes no representations or warranties with respect to
  5. any NetWare software, and specifically disclaims any express or
  6. implied warranties of merchantability, title, or fitness for a
  7. particular purpose.
  8.  
  9. Distribution of any NetWare software is forbidden without the
  10. express written consent of Novell, Inc.  Further, Novell reserves
  11. the right to discontinue distribution of any NetWare software.
  12.  
  13. Novell is not responsible for lost profits or revenue, loss of use
  14. of the software, loss of data, costs of re-creating lost data, the
  15. cost of any substitute equipment or program, or claims by any party
  16. other than you.  Novell strongly recommends a backup be made before
  17. any software is installed.   Technical support for this software
  18. may be provided at the discretion of Novell.
  19. *****************************************************************/
  20. /*
  21.    PROG: ping.c
  22.    LANG: Borland C++ v3.1
  23.    SDK:  NetWare Client SDK v1.0e
  24.    NAME: Jack Gumaer
  25.    DATE: 29-MAR-1995
  26.    VER:  1.0
  27.  
  28.    Revision History: N/A
  29.  
  30.    Description: This sample program queries a particular node
  31.    using the NetWare Diagnostic Services APIs and returns the
  32.    version of IPX, SPX, and NETX loaded on that node.
  33.  
  34.    Usage: ping network address : node address
  35.  
  36.    Example: ping 12341234:112233445566
  37. */
  38.  
  39. #include <stdio.h>
  40. #include <diag.h> /* NetWare Client SDK diagnostics header file */
  41.  
  42. main(int argc,char *argv[])
  43. {  char            i,string[21],string2[2];
  44.     int            j,result,offset,x;
  45.     WORD            connID;
  46.     BYTE            componentList[54];
  47.     BeginDiagnosticStruct    iPXAddress;    /* Same as IPXAddress */
  48.  
  49.     static    AllResponseData       ard;
  50.     static     ShellVersionStruct  svs;
  51.     static   IPXSPXVersion          ipxver;
  52.  
  53.    printf("\nPING Sample Code v1.0 29-MAR-1995");
  54.     if(argc != 2) /* invalid parameters */
  55.     {    printf("\n\nUsage:       ping network:node");
  56.          printf("\nFor example: ping 12341234:0a1b2c3d4e5f\n");
  57.          exit();
  58.     }
  59.  
  60.    /*** Process address parameters ***/
  61.     strcpy(string,argv[1]);
  62.     for(j=0;j<21;j++) /* check for valid data */
  63.     {   string[j] = toupper(string[j]); /* convert to uppercase */
  64.         if((string[j] >47) && (string[j] < 58)) /* it is a number */
  65.         { string[j] = string[j] - 48;
  66.         }
  67.         else
  68.         { if((string[j] > 64) && (string[j] < 71)) /* letters A-F */
  69.           { string[j] = string[j] - 55;
  70.           }
  71.           else
  72.           { if((j==8) && (string[8] == ':')) /* check for : */
  73.              { /* do nothing here */
  74.              }
  75.              else
  76.              { printf("\nError: Invalid data character %d",j+1);
  77.                exit();
  78.              }
  79.           }
  80.         }
  81.     }
  82.  
  83.     /* convert network address */
  84.     for(j=0;j<4;j++)
  85.     {   iPXAddress.network[j] = ((string[j*2]*16)+string[j*2+1]);
  86.     }
  87.  
  88.     /* convert node address */
  89.     for(j=0;j<6;j++)
  90.     {   iPXAddress.node[j] = ((string[(j*2)+9]*16)+string[(j*2)+10]);
  91.     }
  92.  
  93.     /*** Begin Diags ***/
  94.     result = IPXInitialize();
  95.    if(result != 0) /* IPXInitialize() failed */
  96.    {  printf("\nError: IPXInitialize() failed; return code = %X\n",
  97.                 result);
  98.        exit();
  99.     }
  100.     result = BeginDiagnostics(&iPXAddress,&connID,componentList);
  101.     if(result != 0) /* BeginDiagnostics() failed */
  102.     {  printf("\nError: BeginDiagnostics() failed; return code = %X\n",
  103.                 result);
  104.        exit();
  105.     }
  106.    /*** Get IPX/SPX component offset ***/
  107.     offset = FindComponentOffset(componentList,0);
  108.    /*** Get and display IPX/SPX version ***/
  109.     result = GetIPXSPXVersion(connID,(BYTE) offset,&ard,&ipxver);
  110.     if(ard.completionCode == 0)
  111.     {    printf("\nIPX Version: %d.%d",
  112.                 ipxver.IPXMajorVersion,ipxver.IPXMinorVersion);
  113.         printf("\nSPX Version: %d.%d",
  114.                 ipxver.SPXMajorVersion,ipxver.SPXMinorVersion);
  115.     }
  116.     else
  117.     {    printf("\nError getting IPX/SPX version: %d",
  118.                 ard.completionCode);
  119.     }
  120.  
  121.    /*** Get NETX shell component offset ***/
  122.     offset = FindComponentOffset(componentList,3);
  123.    /*** Display shell version ***/
  124.     result = GetShellVersionInfo(connID,(BYTE) offset,&ard,&svs);
  125.     if(ard.completionCode == 0)
  126.     {    printf("\nShell version: %d.%d",svs.major,svs.minor);
  127.     }
  128.     else
  129.     {    printf("\nError getting shell version: %d",ard.completionCode);
  130.     }
  131.  
  132.  
  133.     EndDiagnostics(connID);
  134.     printf("\nEndDiagnostics() return code = %x\n",result);
  135. }
  136.  
  137.