Filter out zero addresses in arp
This commit is contained in:
@@ -79,11 +79,12 @@ data class IpNeighbour(val ip: InetAddress, val dev: String, val lladdr: MacAddr
|
|||||||
val list = arp()
|
val list = arp()
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.filter { parseNumericAddress(it[ARP_IP_ADDRESS]) == ip && it[ARP_DEVICE] in devs }
|
.filter { parseNumericAddress(it[ARP_IP_ADDRESS]) == ip && it[ARP_DEVICE] in devs }
|
||||||
.map { it[ARP_HW_ADDRESS] }
|
.map { MacAddressCompat.fromString(it[ARP_HW_ADDRESS]) }
|
||||||
|
.filter { it != MacAddressCompat.ALL_ZEROS_ADDRESS }
|
||||||
.distinct()
|
.distinct()
|
||||||
.toList()
|
.toList()
|
||||||
when (list.size) {
|
when (list.size) {
|
||||||
1 -> lladdr = MacAddressCompat.fromString(list.single())
|
1 -> lladdr = list.single()
|
||||||
0 -> { }
|
0 -> { }
|
||||||
else -> throw IllegalArgumentException("Unexpected output in arp: ${list.joinToString()}")
|
else -> throw IllegalArgumentException("Unexpected output in arp: ${list.joinToString()}")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user