/** * Checks the status of all network adapters. If one is up and has a valid IP * address, sets mLinkUp to true. Sets mStatusKnown to true if the link status * is definitive. */ void nsNotifyAddrListener::CheckLinkStatus(void) { DWORD ret; const char *event; // This call is very expensive (~650 milliseconds), so we don't want to // call it synchronously. Instead, we just start up assuming we have a // network link, but we'll report that the status is unknown. if (NS_IsMainThread()) { NS_WARNING("CheckLinkStatus called on main thread! No check " "performed. Assuming link is up, status is unknown."); mLinkUp = true; } else { ret = CheckAdaptersAddresses(); if (ret != ERROR_SUCCESS) { mLinkUp = true; } } if (mStatusKnown) event = mLinkUp ? NS_NETWORK_LINK_DATA_UP : NS_NETWORK_LINK_DATA_DOWN; else event = NS_NETWORK_LINK_DATA_UNKNOWN; SendEventToUI(event); }
/** * Checks the status of all network adapters. If one is up and has a valid IP * address, sets mLinkUp to true. Sets mStatusKnown to true if the link status * is definitive. */ void nsNotifyAddrListener::CheckLinkStatus(void) { DWORD ret; const char *event; ret = CheckAdaptersAddresses(); if (ret == ERROR_NOT_SUPPORTED) ret = CheckAdaptersInfo(); if (ret == ERROR_NOT_SUPPORTED) ret = CheckIPAddrTable(); if (ret != ERROR_SUCCESS) mLinkUp = PR_TRUE; // I can't tell, so assume there's a link if (mStatusKnown) event = mLinkUp ? NS_NETWORK_LINK_DATA_UP : NS_NETWORK_LINK_DATA_DOWN; else event = NS_NETWORK_LINK_DATA_UNKNOWN; SendEventToUI(event); }