Loading nexus/IControllerHandler.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -22,8 +22,8 @@ class InterfaceConfig; class IControllerHandler { class IControllerHandler { public: public: virtual void onInterfaceStarted(Controller *c, const InterfaceConfig *cfg) = 0; virtual void onInterfaceConnected(Controller *c, const InterfaceConfig *cfg) = 0; virtual void onInterfaceStopping(Controller *c, const char *name) = 0; virtual void onInterfaceDisconnected(Controller *c, const char *name) = 0; }; }; #endif #endif Loading nexus/NetworkManager.cpp +14 −7 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "NetworkManager.h" #include "NetworkManager.h" #include "InterfaceConfig.h" #include "InterfaceConfig.h" #include "DhcpClient.h" NetworkManager *NetworkManager::sInstance = NULL; NetworkManager *NetworkManager::sInstance = NULL; Loading @@ -36,6 +37,7 @@ NetworkManager::NetworkManager(PropertyManager *propMngr) { mBroadcaster = NULL; mBroadcaster = NULL; mControllers = new ControllerCollection(); mControllers = new ControllerCollection(); mPropMngr = propMngr; mPropMngr = propMngr; mDhcp = new DhcpClient(this); } } NetworkManager::~NetworkManager() { NetworkManager::~NetworkManager() { Loading Loading @@ -89,8 +91,8 @@ Controller *NetworkManager::findController(const char *name) { return NULL; return NULL; } } void NetworkManager::onInterfaceStarted(Controller *c, const InterfaceConfig *cfg) { void NetworkManager::onInterfaceConnected(Controller *c, const InterfaceConfig *cfg) { LOGD("Interface %s started by controller %s", c->getBoundInterface(), c->getName()); LOGD("Controller %s interface %s connected", c->getName(), c->getBoundInterface()); // Look up the interface // Look up the interface Loading @@ -98,9 +100,9 @@ void NetworkManager::onInterfaceStarted(Controller *c, const InterfaceConfig *cf } } if (cfg) { if (cfg) { if (cfg->getUseDhcp()) { if (cfg->getUseDhcp() && mDhcp->start(c->getBoundInterface())) { // Launch DHCP thread LOGE("DHCP start failed"); } else { } else if (!cfg->getUseDhcp()) { // Static configuration // Static configuration } } } else { } else { Loading @@ -109,6 +111,11 @@ void NetworkManager::onInterfaceStarted(Controller *c, const InterfaceConfig *cf } } } } void NetworkManager::onInterfaceStopping(Controller *c, const char *name) { void NetworkManager::onInterfaceDisconnected(Controller *c, const char *name) { LOGD("Interface %s stopped by controller %s", name, c->getName()); LOGD("Controller %s interface %s disconnected", c->getName(), name); // If we have a DHCP request out on this interface then stop it if (1) { mDhcp->stop(); } } } nexus/NetworkManager.h +6 −3 Original line number Original line Diff line number Diff line Loading @@ -22,10 +22,12 @@ #include "Controller.h" #include "Controller.h" #include "PropertyManager.h" #include "PropertyManager.h" #include "IControllerHandler.h" #include "IControllerHandler.h" #include "IDhcpEventHandlers.h" class InterfaceConfig; class InterfaceConfig; class DhcpClient; class NetworkManager : public IControllerHandler { class NetworkManager : public IControllerHandler, public IDhcpEventHandlers { private: private: static NetworkManager *sInstance; static NetworkManager *sInstance; Loading @@ -33,6 +35,7 @@ private: ControllerCollection *mControllers; ControllerCollection *mControllers; SocketListener *mBroadcaster; SocketListener *mBroadcaster; PropertyManager *mPropMngr; PropertyManager *mPropMngr; DhcpClient *mDhcp; public: public: virtual ~NetworkManager(); virtual ~NetworkManager(); Loading @@ -55,7 +58,7 @@ private: NetworkManager(PropertyManager *propMngr); NetworkManager(PropertyManager *propMngr); void onInterfaceStarted(Controller *c, const InterfaceConfig *cfg); void onInterfaceConnected(Controller *c, const InterfaceConfig *cfg); void onInterfaceStopping(Controller *c, const char *name); void onInterfaceDisconnected(Controller *c, const char *name); }; }; #endif #endif nexus/WifiController.cpp +22 −24 Original line number Original line Diff line number Diff line Loading @@ -279,7 +279,6 @@ void WifiController::onAssociatedEvent(SupplicantAssociatedEvent *evt) { void WifiController::onConnectedEvent(SupplicantConnectedEvent *evt) { void WifiController::onConnectedEvent(SupplicantConnectedEvent *evt) { LOGD("onConnectedEvent(%s, %d)", evt->getBssid(), evt->getReassociated()); LOGD("onConnectedEvent(%s, %d)", evt->getBssid(), evt->getReassociated()); if (!evt->getReassociated()) { SupplicantStatus *ss = mSupplicant->getStatus(); SupplicantStatus *ss = mSupplicant->getStatus(); WifiNetwork *wn; WifiNetwork *wn; Loading @@ -304,8 +303,7 @@ void WifiController::onConnectedEvent(SupplicantConnectedEvent *evt) { } } delete ss; delete ss; mHandlers->onInterfaceStarted(this, wn->getIfaceCfg()); mHandlers->onInterfaceConnected(this, wn->getIfaceCfg()); } } } void WifiController::onScanResultsEvent(SupplicantScanResultsEvent *evt) { void WifiController::onScanResultsEvent(SupplicantScanResultsEvent *evt) { Loading Loading @@ -373,7 +371,7 @@ void WifiController::onConnectionTimeoutEvent(SupplicantConnectionTimeoutEvent * } } void WifiController::onDisconnectedEvent(SupplicantDisconnectedEvent *evt) { void WifiController::onDisconnectedEvent(SupplicantDisconnectedEvent *evt) { LOGD("onDisconnectedEvent()"); mHandlers->onInterfaceDisconnected(this, getBoundInterface()); } } #if 0 #if 0 Loading Loading
nexus/IControllerHandler.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -22,8 +22,8 @@ class InterfaceConfig; class IControllerHandler { class IControllerHandler { public: public: virtual void onInterfaceStarted(Controller *c, const InterfaceConfig *cfg) = 0; virtual void onInterfaceConnected(Controller *c, const InterfaceConfig *cfg) = 0; virtual void onInterfaceStopping(Controller *c, const char *name) = 0; virtual void onInterfaceDisconnected(Controller *c, const char *name) = 0; }; }; #endif #endif Loading
nexus/NetworkManager.cpp +14 −7 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "NetworkManager.h" #include "NetworkManager.h" #include "InterfaceConfig.h" #include "InterfaceConfig.h" #include "DhcpClient.h" NetworkManager *NetworkManager::sInstance = NULL; NetworkManager *NetworkManager::sInstance = NULL; Loading @@ -36,6 +37,7 @@ NetworkManager::NetworkManager(PropertyManager *propMngr) { mBroadcaster = NULL; mBroadcaster = NULL; mControllers = new ControllerCollection(); mControllers = new ControllerCollection(); mPropMngr = propMngr; mPropMngr = propMngr; mDhcp = new DhcpClient(this); } } NetworkManager::~NetworkManager() { NetworkManager::~NetworkManager() { Loading Loading @@ -89,8 +91,8 @@ Controller *NetworkManager::findController(const char *name) { return NULL; return NULL; } } void NetworkManager::onInterfaceStarted(Controller *c, const InterfaceConfig *cfg) { void NetworkManager::onInterfaceConnected(Controller *c, const InterfaceConfig *cfg) { LOGD("Interface %s started by controller %s", c->getBoundInterface(), c->getName()); LOGD("Controller %s interface %s connected", c->getName(), c->getBoundInterface()); // Look up the interface // Look up the interface Loading @@ -98,9 +100,9 @@ void NetworkManager::onInterfaceStarted(Controller *c, const InterfaceConfig *cf } } if (cfg) { if (cfg) { if (cfg->getUseDhcp()) { if (cfg->getUseDhcp() && mDhcp->start(c->getBoundInterface())) { // Launch DHCP thread LOGE("DHCP start failed"); } else { } else if (!cfg->getUseDhcp()) { // Static configuration // Static configuration } } } else { } else { Loading @@ -109,6 +111,11 @@ void NetworkManager::onInterfaceStarted(Controller *c, const InterfaceConfig *cf } } } } void NetworkManager::onInterfaceStopping(Controller *c, const char *name) { void NetworkManager::onInterfaceDisconnected(Controller *c, const char *name) { LOGD("Interface %s stopped by controller %s", name, c->getName()); LOGD("Controller %s interface %s disconnected", c->getName(), name); // If we have a DHCP request out on this interface then stop it if (1) { mDhcp->stop(); } } }
nexus/NetworkManager.h +6 −3 Original line number Original line Diff line number Diff line Loading @@ -22,10 +22,12 @@ #include "Controller.h" #include "Controller.h" #include "PropertyManager.h" #include "PropertyManager.h" #include "IControllerHandler.h" #include "IControllerHandler.h" #include "IDhcpEventHandlers.h" class InterfaceConfig; class InterfaceConfig; class DhcpClient; class NetworkManager : public IControllerHandler { class NetworkManager : public IControllerHandler, public IDhcpEventHandlers { private: private: static NetworkManager *sInstance; static NetworkManager *sInstance; Loading @@ -33,6 +35,7 @@ private: ControllerCollection *mControllers; ControllerCollection *mControllers; SocketListener *mBroadcaster; SocketListener *mBroadcaster; PropertyManager *mPropMngr; PropertyManager *mPropMngr; DhcpClient *mDhcp; public: public: virtual ~NetworkManager(); virtual ~NetworkManager(); Loading @@ -55,7 +58,7 @@ private: NetworkManager(PropertyManager *propMngr); NetworkManager(PropertyManager *propMngr); void onInterfaceStarted(Controller *c, const InterfaceConfig *cfg); void onInterfaceConnected(Controller *c, const InterfaceConfig *cfg); void onInterfaceStopping(Controller *c, const char *name); void onInterfaceDisconnected(Controller *c, const char *name); }; }; #endif #endif
nexus/WifiController.cpp +22 −24 Original line number Original line Diff line number Diff line Loading @@ -279,7 +279,6 @@ void WifiController::onAssociatedEvent(SupplicantAssociatedEvent *evt) { void WifiController::onConnectedEvent(SupplicantConnectedEvent *evt) { void WifiController::onConnectedEvent(SupplicantConnectedEvent *evt) { LOGD("onConnectedEvent(%s, %d)", evt->getBssid(), evt->getReassociated()); LOGD("onConnectedEvent(%s, %d)", evt->getBssid(), evt->getReassociated()); if (!evt->getReassociated()) { SupplicantStatus *ss = mSupplicant->getStatus(); SupplicantStatus *ss = mSupplicant->getStatus(); WifiNetwork *wn; WifiNetwork *wn; Loading @@ -304,8 +303,7 @@ void WifiController::onConnectedEvent(SupplicantConnectedEvent *evt) { } } delete ss; delete ss; mHandlers->onInterfaceStarted(this, wn->getIfaceCfg()); mHandlers->onInterfaceConnected(this, wn->getIfaceCfg()); } } } void WifiController::onScanResultsEvent(SupplicantScanResultsEvent *evt) { void WifiController::onScanResultsEvent(SupplicantScanResultsEvent *evt) { Loading Loading @@ -373,7 +371,7 @@ void WifiController::onConnectionTimeoutEvent(SupplicantConnectionTimeoutEvent * } } void WifiController::onDisconnectedEvent(SupplicantDisconnectedEvent *evt) { void WifiController::onDisconnectedEvent(SupplicantDisconnectedEvent *evt) { LOGD("onDisconnectedEvent()"); mHandlers->onInterfaceDisconnected(this, getBoundInterface()); } } #if 0 #if 0 Loading