Use all zeros for wtf MAC
This commit is contained in:
@@ -43,7 +43,11 @@ data class IpNeighbour(val ip: InetAddress, val dev: String, val lladdr: Long, v
|
||||
.filter { parseNumericAddress(it[ARP_IP_ADDRESS]) == ip && it[ARP_DEVICE] == dev }
|
||||
.map { it[ARP_HW_ADDRESS] }
|
||||
.singleOrNull() ?: "")
|
||||
if (lladdr.isEmpty()) return emptyList()
|
||||
val mac = if (lladdr.isEmpty()) {
|
||||
if (match.groups[4] == null) return emptyList()
|
||||
Timber.w(IOException("Failed to find MAC address for $line"))
|
||||
0
|
||||
} else lladdr.macToLong()
|
||||
val state = if (match.groupValues[1].isNotEmpty()) State.DELETING else
|
||||
when (match.groupValues[7]) {
|
||||
"", "INCOMPLETE" -> State.INCOMPLETE
|
||||
@@ -52,13 +56,13 @@ data class IpNeighbour(val ip: InetAddress, val dev: String, val lladdr: Long, v
|
||||
"NOARP" -> return emptyList() // skip
|
||||
else -> throw IllegalArgumentException("Unknown state encountered: ${match.groupValues[7]}")
|
||||
}
|
||||
val result = IpNeighbour(ip, dev, lladdr.macToLong(), state)
|
||||
val result = IpNeighbour(ip, dev, mac, state)
|
||||
val devParser = devFallback.matchEntire(dev)
|
||||
if (devParser != null) try {
|
||||
val index = devParser.groupValues[1].toInt()
|
||||
val iface = NetworkInterface.getByIndex(index)
|
||||
if (iface == null) Timber.w("Failed to find network interface #$index")
|
||||
else return listOf(IpNeighbour(ip, iface.name, lladdr.macToLong(), state), result)
|
||||
else return listOf(IpNeighbour(ip, iface.name, mac, state), result)
|
||||
} catch (_: SocketException) { }
|
||||
listOf(result)
|
||||
} catch (e: Exception) {
|
||||
|
||||
Reference in New Issue
Block a user