home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / NOVELL / DIGNLM.ZIP / DIAGNLM
Encoding:
Text File  |  1990-10-31  |  11.9 KB  |  350 lines

  1. #define EXT_DIAG_SOCKET 0x5684      /* hi-lo order */
  2. #define COUNT 5
  3. #define SEND 3
  4. typedef struct
  5. {
  6.       char  objectName[48];
  7.       WORDobjectType;
  8.       long  objectID;
  9.       BYTE  loginTime[7];
  10. }connInfo;
  11.  
  12. typedef struct
  13. {
  14.       unsigned char majorVersion;
  15.       unsigned char minorVersion;
  16.       unsigned short SPXsocket;
  17.       BYTE numComponents;
  18.       BYTE IPXSPXcomponent;
  19.       BYTE bridgeComponent;
  20.       BYTE serverComp[13];
  21. } identData;
  22.  
  23. unsigned short SPXDiagSocket;
  24. unsigned  char networkAddress[10];
  25. extern unsigned long mySem;
  26.  
  27. NodeIdent(unsigned char *reqNode)
  28. {
  29.       int                     ccode;
  30.       unsigned short revision;
  31.       identData               ident;
  32.       IPX_HEADER              identSend;
  33.       IPX_ECB                 identECB;
  34.       unsigned longtransportTime;
  35.  
  36.       ccode = IpxGetVersion(&(ident.majorVersion),
  37.                                                  &(ident.minorVersion),
  38.                                                  &revision);
  39.       if (ccode)
  40.             return 0xFF;
  41.       ident.SPXsocket  = SPXDiagSocket;
  42.       ident.numComponents  = 3;
  43.       ident.IPXSPXcomponent  = 0;
  44.       ident.bridgeComponent  = 1;
  45.       ident.serverComp[0]  = 6;
  46.       ident.serverComp[1]  = '?';
  47.       ident.serverComp[2]  = 4;
  48.       memcpy(&(ident.serverComp[3]), networkAddress, 10);
  49.       memcpy(identSend.destNet, reqNode, 12);
  50.       identSend.packetLen  = (sizeof(IPX_HEADER)  + sizeof(identData));
  51.       identECB.queueHead  = 0x00;
  52.       identECB.socket  = EXT_DIAG_SOCKET;
  53.       identECB.fragCount  = 2;
  54.       identECB.fragList[0].fragAddress   = (IPX_ECB *)&identSend;
  55.       identECB.fragList[0].fragSize  = (unsigned long)sizeof(IPX_HEADER);
  56.       identECB.fragList[1].fragAddress  = (IPX_HEADER *)&ident;
  57.       identECB.fragList[1].fragSize  = sizeof(identData);
  58.  
  59.       ccode  = IpxGetLocalTarget(reqNode,  &identECB,  &transportTime);
  60.       if (ccode)
  61.             return 0xFF;
  62.  
  63.       ccode  = IpxSend(EXT_DIAG_SOCKET, &identECB);
  64.       if (ccode)
  65.             return (ccode);
  66.       ccode  = WaitOnLocalSemaphore(mySem);
  67.       return ccode;
  68. }
  69.  
  70. ServConfig(unsigned  char *reqNode)
  71. {
  72.       int ccode;
  73.       FILE_SERV_INFO serverInfo;
  74.       IPX_HEADER              infoSend;
  75.       IPX_ECB                 infoECB;
  76.       unsigned longtransportTime;
  77.       
  78.       ccode  = GetServerInformation(59,  (FILE_SERV_INFO  *)&serverInfo);
  79.       if (ccode)
  80.             return 0xFF;
  81.       /* fill in the packet header and the ECB.
  82.             The second frag is the serverInfo struct.*/
  83.       memcpy(infoSend.destNet, reqNode, 12);
  84.       infoSend.packetLen  = (sizeof(IPX_HEADER)  + 59);
  85.       infoECB.queueHead  = 0x00;
  86.       info ECB.socket  = EXT_DIAG_SOCKET;
  87.       infoECB.fragCount  = 2;
  88.       infoECB.fragList[0].fragAddress  = (IPX_ECB  *)&infoSend;
  89.       infoECB.fragList[0].fragSize  = (unsigned long)sizeof(IPX_HEADER);
  90.       infoECB.fragList[1].fragAddress  = (IPX_HEADER  *)&serverInfo;
  91.       infoECB.fragList[1].fragSize  = (unsigned long)59;
  92.  
  93.       ccode  = IpxGetLocalTarget(reqNode,  &infoECB,  &transportTime);
  94.       if (ccode)
  95.             return 0xFF;
  96.  
  97.       ccode  = IpxSend(EXT_DIAG_SOCKET,  &infoECB);
  98.       if (ccode)
  99.             return (ccode);
  100.       CCODE  = WaitOnLocalSemaphore(mySem);
  101.       return ccode;
  102. }
  103.  
  104.  
  105. ReturnConnectionTable(unsigned  char *reqNode, unsigned short connID)
  106. {
  107.       int ccode,i;
  108.       SPX_ECB     connECB;
  109.       SPX_HEADER  connSend;
  110.       struct
  111.       {
  112.             int numConnections;
  113.             connInfo    connTable[5];
  114.       }retBuf;
  115.       unsigned longtransportTime;
  116.       
  117.       for (i=1; i<=5; i++)
  118.       {
  119.             ccode  = GetConnectionInformation(i,
  120.  
  121.                   retBuf.connTable[i-1].objectName, 
  122.  
  123.                   &(retBuf.connTable[i-1].objectType), 
  124.  
  125.                   &(retBuf.connTable[i-1].objectID), 
  126.  
  127.                   &(retBuf.connTable[i-1].loginTime));
  128.             }
  129.             retBuf.numConnections  = 5;
  130.       /* fill in the packet header and the ECB.
  131.             The second frag is the connTable struct.*/
  132.       memcpy(connSend.destNet,  reqNode, 12);
  133.       connSend.packetLen  = (sizeof(IPX_HEADER)  + sizeof(retBuf));
  134.       connECB.queueHead  = 0x00;
  135.       connECB.semHandle  = mySem;
  136.       connECB.socket  = EXT_DIAG_SOCKET;
  137.       connECB.fragCount  = 2;
  138.       connECB.fragList[0].fragAddress  = (IPX_ECB  *)&connSend;
  139.       connECB.fragList[0].fragSize  = sizeof(IPX_HEADER);
  140.       connECB.fragList[1].fragAddress  = (IPX_HEADER  *)&retBuf;
  141.       connECB.fragList[1].fragSize  = sizeof(retBuf);
  142.  
  143.       ccode  = SpxSendSequencedPacket(connID,  &connECB);
  144.       if (ccode)
  145.             return (ccode);
  146.       ccode  = WaitOnLocalSemaphore(mySem);
  147.       return ccode;
  148. }
  149.  
  150. KnownNetworks(unsigned  char *reqNode, unsigned short connID)
  151. {
  152.       int ccode,i;
  153.       SPX_HEADER              netSend;
  154.       SPX_ECB                 netECB;
  155.       struct
  156.       {
  157.             int   ccode;
  158.             int   intervalMarker;
  159.             int   numNetworks;
  160.             unsigned longnetTable[5];
  161.       } retBuf;
  162.       unsigned longtransportTime;
  163.       long                    objectID;
  164.       char                    objName[48], objHasProp, objFlag, objSec;
  165.       WORD              objType;
  166.       BYTE                    propValue[128], moreSegments, propertyFlags;
  167.       
  168.       for (i=1; i<=5; i++)
  169.       {
  170.             ccode  = ScanBinderyObject("*", (WORD) 4
  171.                                                             &objectID, &objName,
  172.                                                             &objType, &objHasProp,
  173.                                                             &objFlag, &objSec);
  174.             if (ccode)
  175.                   return 0xFF;
  176.             ccode  = ReadPropertyValue(objName, objType, "NET_ADDRESS", (int) 1,
  177.                                                             propValue,
  178.  &moreSegments, &propertyFlags);
  179.             if (ccode)
  180.                   return 0xFF;
  181.             memcpy(retBuf.netTable[i-1], propValue, 4);
  182.       }
  183.       retBuf.ccode  = 0;
  184.       retBuf.intervalMarker  = 0xFF;
  185.       retBuf.numNetworks  = 5;
  186.       /* fill in the packet header and the ECB.
  187.             The second frag is the netTable struct.*/
  188.       memcpy(netSend.destNet,  reqNode, 12);
  189.       netSend.packetLen  = (sizeof(IPX_HEADER) + sizeof(retBuf));
  190.       netECB.queueHead  = 0x00;
  191.       netECB.semHandle  = mySem;
  192.       netECB.socket  = EXT_DIAG_SOCKET;
  193.       netECB.fragCount  = 2;
  194.       netECB.fragList[0].fragAddress  = (IPX_ECB  *)&netSend;
  195.       netECB.fragList[0].fragSize  = sizeof(IPX_HEADER);
  196.       netECB.fragList[1].fragAddress  = (IPX_HEADER  *)&retBuf;
  197.       netECB.fragList[1].fragSize  = sizeof(retBuf);
  198.  
  199.       ccode  = SpxSendSequencedPacket(connID,  &netECB);
  200.       if (ccode)
  201.             return (ccode);
  202.       ccode  = WaitOnLocalSemaphore(mySem);
  203.       return ccode;
  204. }
  205.  
  206. KnownServers(unsigned  char *reqNode, unsigned short connID)
  207. {
  208.       int ccode,i;
  209.       struct
  210.       {
  211.             int   ccode;
  212.             int   intervalMarker;
  213.             int   numNetworks;
  214.             char                    servTable[5][48];
  215.       } retBuf;
  216.       IPX_HEADER              servSend;
  217.       IPX_ECB                 servECB;
  218.       unsigned longtransportTime;
  219.       long                    objectID;
  220.       char                    objName[48], objHasProp, objFlag, objSec;
  221.       WORD              objType;
  222.       
  223.       for (i=1; i<=5; i++)
  224.       {
  225.             ccode  = ScanBinderyObject("*", (WORD) 4,
  226.                                                             &objectID,
  227.  retBuf.servTable[i-1],
  228.                                                             &objType,
  229.  &objHasProp,
  230.                                                             &objFlag, &objSec);
  231.             if (ccode)
  232.                   return 0xFF;
  233.       }
  234.       retBuf.ccode  = 0;
  235.       retBuf.intervalMarker  = 0xFF;
  236.       retBuf.numNetworks  = 5;
  237.       /* fill in the packet header and the ECB.
  238.             The second frag is the servTable. */
  239.       memcpy(servSend.destNet, reqNode, 12);
  240.       servSend.packetLen  = (sizeof(IPX_HEADER)  + sizeof(retBuf));
  241.       servECB.queueHead  = 0x00;
  242.       servECB.semHandle  = mySem;
  243.       servECB.socket  = EXT_DIAG_SOCKET;
  244.       servECB.fragCount  = 2;
  245.       servECB.fragList[0].fragAddress  = (IPX_ECB  *)&servSend;
  246.       servECB.fragList[0].fragSize  = sizeof(IPX_HEADER);
  247.       servECB.fragList[1].fragAddress  = (IPX_ECB  *)&retBuf;
  248.       servECB.fragList[1].fragSize  = sizeof(retBuf);
  249.  
  250.       ccode  = SpxSendSequencedPacket(connID,  &servECB);
  251.       if (ccode)
  252.             return (ccode);
  253.       ccode  = WaitOnLocalSemaphore(mySem);
  254.       return ccode;
  255.       
  256. }
  257.  
  258. PointTest(unsigned  char request, InternetAddress *dest,
  259.                   WORD numPackets, BYTE *immediateAddress,
  260.                   WORD packetSize, unsigned short socket)
  261. {
  262.       int                     ccode, i, count;
  263.       IPX_HEADER              pointTest;
  264.       IPX_ECB                 pointECB;
  265.       BYTE                    data[512];
  266.  
  267.       memcpy(pointTest.destNet,  dest, 12);
  268.       pointTest.packetLen   = packetSize;
  269.       pointECB.queueHead   = 0x00
  270.       memcpy(pointECB.socket,  socket, 2);
  271.       memcpy(pointECB.immediateAddress,  immediateAddress,  6);
  272.       pointECB.fragCount   = 2;
  273.       pointECB.fragList[0].fragAddress   = (IPX_ECB  *)&pointTest;
  274.       pointECB.fragList[0].fragSize   = sizeof(IPX_HEADER);
  275.       pointECB.fragList[1].fragAddress   = (IPX_ECB  *)data;
  276.       pointECB.fragList[1].fragSize   = sizeof(data);
  277.  
  278.       switch(request)
  279.       {
  280.             case SEND;
  281.                   for (i=1; i<=numPackets;  i++)
  282.                   {
  283.                         ccode  = IpxSend(0x00, &pointECB);
  284.                         if (ccode)
  285.                               return ccode;
  286.                         ccode  = WaitOnLocalSemaphore(mySem);
  287.                         if (ccode)
  288.                               return ccode;
  289.                   }
  290.                   break;
  291.             case COUNT;
  292.                   while (count < numPackets)
  293.                   {
  294.                         ccode  = IpxReceive(0x00,  &pointECB);
  295.                         if (ccode)
  296.                               return ccode;
  297.                         ccode  = WaitOnLocalSemaphore(mySem);
  298.                         if (ccode)
  299.                               return ccode;
  300.                   }
  301.                   break;
  302.             default :
  303.                   return 0xFF;
  304.       }
  305. }
  306.  
  307. /* module from workstation program */
  308. #define EXT_DIAG_SOCKET  0x5684   /*hi-lo 0x8456 */
  309. #define DIAG_SOCKET  0x5604
  310.  
  311. /* This module shows sending only the first broadcast with no exclusions */
  312. /* The listens for the responses could be posted here or in another module */
  313.  
  314. void GetIdent(void)
  315. {
  316.       IPXHeader   identSend;
  317.       ECB         identECB;
  318.       struct
  319.       {
  320.             BYTE numExclusions;
  321.             BYTE exclAddress[80][6];
  322.       } data;
  323.  
  324.       memset(identSend.destination.network,  0, 4);
  325.       memset(identSend.destination.node,  0xFF, 6);
  326.       identSend.destination.socket[0]   = 0x04;
  327.       identSend.destination.socket[0]   = 0x56;
  328.       identSend.packetType   = 0x04;
  329.       identSend.length   = (sizeof(IPXHeader)   + sizeof(data));
  330.       identECB.ESRAddress   = 0x00;
  331.       memset(identECB.immediateAddress,  0xFF, 6);
  332.       identECB.socketNumber   = DIAG_SOCKET;
  333.       identECB.fragmentCount   = 2;
  334.       identECB.fragmentDescriptor[0].address   = (char far  *)&identSend;
  335.       identECB.fragmentDescriptor[0].size   = sizeof(IPXHeader);
  336.       identECB.fragmentDescriptor[1].address   = (char far  *)&data;
  337.       identECB.fragmentDescriptor[1].size   = sizeof(data);
  338.  
  339.       IPXSendPacket(&identECB);
  340.       while (identECB.inUseFlag);
  341.  
  342.       identSend.destination.socket[0]   = 0x84;
  343.       identSend.destination.socket[0]   = 0x56;
  344.       identECB.socketNumber   = EXT_DIAG_SOCKET;
  345.  
  346.       IPXSendPacket(&identECB);
  347.       while (identECB.inUseFlag);
  348.       return;
  349. }
  350.