long reCaculatedLeaseMillis = mPastDhcpLease.systemExpiredTime - SystemClock.elapsedRealtime(); Log.d(TAG, "IP recover: reCaculatedLeaseMillis = " + reCaculatedLeaseMillis);
if (reCaculatedLeaseMillis < 0) { // configure infinite lease mDhcpLeaseExpiry = 0; Log.e(TAG, "IP recover: lease had been expired! configure to infinite lease"); } else { mDhcpLeaseExpiry = SystemClock.elapsedRealtime() + reCaculatedLeaseMillis; Log.d(TAG, "IP recover: mDhcpLeaseExpiry = " + mDhcpLeaseExpiry); }
byte arpResult[] = null; ArpPeer ap = null; boolean retVal = false; try { InetAddress ipAddress = mPastDhcpLease.ipAddress.getAddress(); Log.d(TAG, "IP recover: arp address = " + "#$%K" + logDumpIpv4(3, ipAddress.getHostAddress())); ap = new ArpPeer(mIfaceName, Inet4Address.ANY, ipAddress); // doArp will blocking several seconds, to create thread if needed arpResult = ap.doArp(5000); if (arpResult == null) { int leaseDuration = (int)reCaculatedLeaseMillis/1000; mPastDhcpLease.setLeaseDuration(leaseDuration); acceptDhcpResults(mPastDhcpLease, "Confirmed"); Log.d(TAG, "doIpRecover no arp response, IP can be reused"); retVal = true; } else { Log.d(TAG, "doIpRecover DAD detected!!"); } } catch (ErrnoException ee) { Log.d(TAG, "err :" + ee); } catch (IllegalArgumentException ie) { Log.d(TAG, "err :" + ie); } catch (SocketException se) { Log.d(TAG, "err :" + se); } finally { if (ap != null) ap.close(); } return retVal; } /// @}