Skip to content

Commit 91b8dce

Browse files
Merge pull request stealthcopter#23 from Alamusitl/feature/develop
Update SubnetDevices.java
2 parents 7eabe56 + cd41888 commit 91b8dce

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

library/src/main/java/com/stealthcopter/networktools/SubnetDevices.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,10 @@ public static SubnetDevices fromIPAddress(@NonNull final String ipAddress) {
7070
subnetDevice.addresses.addAll(ARPInfo.getAllIPAddressesInARPCache());
7171

7272
// Add all missing addresses in subnet
73+
String segment = ipAddress.substring(0, ipAddress.lastIndexOf(".") + 1);
7374
for (int j = 0; j < 255; j++) {
74-
if (!subnetDevice.addresses.contains(ipAddress + j)) {
75-
subnetDevice.addresses.add(ipAddress + j);
75+
if (!subnetDevice.addresses.contains(segment + j)) {
76+
subnetDevice.addresses.add(segment + j);
7677
}
7778
}
7879

@@ -160,4 +161,4 @@ public void run() {
160161
}
161162
}
162163

163-
}
164+
}

0 commit comments

Comments
 (0)