// If loc delegate is provided, this function passes an integer value // of the current index relative to the length of the range // If ip delegate is provided, this function passes the current IP // to the delegate public async Task buildIPTableAsync(Del locDel, IPDel ipDel) { Byte[] startIP = startRange.GetAddressBytes(); Byte[] endIP = endRange.GetAddressBytes(); Byte[] originalEndIP = endRange.GetAddressBytes(); IPAddress currIP; //setRangeLength(); long currAddress; int loc = 0; for (int i = startIP[0]; i <= endIP[0]; i++) { // Iterate through i.j.k.l if (i < endIP[0]) // If the start MSB < end MSB, { endIP[1] = 255; // then ensure all ranges are looped through } else { endIP[1] = originalEndIP[1]; } for (int j = startIP[1]; j <= endIP[1]; j++) { if (j < endIP[1]) { endIP[2] = 255; } else { endIP[2] = originalEndIP[2]; } for (int k = startIP[2]; k <= endIP[2]; k++) { if (k < endIP[2]) { endIP[3] = 255; } else { endIP[3] = originalEndIP[3]; } for (int l = startIP[3]; l <= endIP[3]; l++, loc++) { currAddress = generateIPAddress((uint)l, (uint)k, (uint)j, (uint)i); currIP = new IPAddress(currAddress); if (locDel != null) { locDel(loc); } if (ipDel != null) { ipDel(currIP); } readHTML(currIP); await Task.Delay(50); Debug.Write(currIP + "\n"); } startIP[3] = 0; // When any level of the loop reaches } // its end, set the start value to 0 startIP[2] = 0; // so any future loops go through the } // entire address range startIP[1] = 0; } startIP[0] = 0; }
public async Task buildIPTableAsync(IPDel ipDel) { await buildIPTableAsync(null, ipDel); }