/* Allnets.c - print out all the networks using diagnostic services Copyright (c) 1992 A.R.Goodkin Academic Information Services University of Salford Salford Great Britain M5 4WT To rebuild use something like: bcc -ms -f- -O -P-C -Qe- -Qx -Lh: -I\netware\includes allnets.c \netware\nitlib\snit.lib */ #include #include #include #include #include #include void main () { WORD connID; int err; BYTE component; WORD nextNetworkOffset; AllResponseData response; AllKnownNetworksStruct responseData; int number; int i; BYTE FSaddress [12]; BYTE componentlist [54]; IPXInitialize (); connID = GetDefaultConnectionID (); FSnet (connID, FSaddress); #ifdef DEBUG printf ("connection ID is %d\n", connID); printf ("Network number is %08lX\n", LongSwap (*((long *) &FSaddress [0]))); printf ("Physical node address is %08lX%04X\n", LongSwap (*((long *) &FSaddress [4])), IntSwap (*((int*) &FSaddress [8]))); printf ("Socket number is %04X\n", IntSwap (*((int*) &FSaddress [10]))); /* if (err = IPXOpenSocket (&FSaddress [10], 0x00)) {printf ("IPXOpenSocket failed (%d)", err); return;} printf ("New socket number is %04X\n", IntSwap (*((int*) &FSaddress [10]))); */ #endif if (err = BeginDiagnostics (FSaddress, &connID, componentlist)) {printf ("BeginDiagnostics failed (%d)", err); return;} component = (BYTE) FindComponentOffset (componentlist, (BYTE) 6); nextNetworkOffset = 0; #ifdef DEBUG printf ("connection ID = %d component = %d\n", connID, component); #endif while (!(err = GetAllKnownNetworks (connID, component, nextNetworkOffset, &response, &responseData))) { number = responseData.numberOfNetworkAddresses; printf ("number of networks = %d\n", number); for (i = 0; i < number; i++) { printf ("%08lX\n", LongSwap (*((long *) responseData.networkAddress[i].address))); } if (number < 128) break; nextNetworkOffset = 128; } if (err) {printf ("GetAllKnownNetworks failed (%d)", err); return;} EndDiagnostics (connID); } FSnet (WORD connectionID, BYTE *FSaddress) { int ccode; BYTE far * connectionTableptr; /* pointer to table in workstation's */ /* memory of connection id 8 x 32 array */ int j, k; ccode = _TableReq(0xef, 0x03, &connectionTableptr); if (ccode != 0) return; j = ((connectionID -1) * 32) + 2; /* address is offset 2 */ for (k = 0; k < 12; k++,j++) FSaddress [k] = connectionTableptr [j]; }