diff --git a/wpa_actiond.c b/wpa_actiond.c index d60d885..03a9d7f 100644 --- a/wpa_actiond.c +++ b/wpa_actiond.c @@ -292,6 +292,7 @@ static void loop(const char *iface, const char *ctrlpath, const int disconnect_t /* path to control socket */ char *ctrlsock = NULL; int ctrlsocklen; + int pong_failures = 0; ssid[0] = '\0'; old_ssid[0] = '\0'; @@ -359,6 +360,7 @@ static void loop(const char *iface, const char *ctrlpath, const int disconnect_t } logevent(WPA_ACTIOND_LOG_TERMINATE, iface, ""); state = WPA_ACTIOND_STATE_TERMINATED; + pong_failures = 0; break; case 0: if (state == WPA_ACTIOND_STATE_CONNECTION_LOST) { @@ -372,8 +374,15 @@ static void loop(const char *iface, const char *ctrlpath, const int disconnect_t reply_len = 0; reply[reply_len] = '\0'; if(!str_match(reply, "PONG")) { + if (pong_failures <= 3) { + logevent(WPA_ACTIOND_LOG_CUSTOM_ERROR, iface, "wpa_supplicant failed to reply (PONG)"); + pong_failures++; + break; + } + /* supplicant has been terminated */ if(state == WPA_ACTIOND_STATE_CONNECTED || state == WPA_ACTIOND_STATE_CONNECTION_LOST) { + logevent(WPA_ACTIOND_LOG_CUSTOM_ERROR, iface, "wpa_supplicant failed to reply three times in a row - disconnecting"); logevent(WPA_ACTIOND_LOG_DISCONNECTED, iface, ssid); action(WPA_ACTIOND_ACTION_DISCONNECT, iface, ssid, idstr, wpa_ctrl_get_fd(ctrl), script); } @@ -381,6 +390,7 @@ static void loop(const char *iface, const char *ctrlpath, const int disconnect_t state = WPA_ACTIOND_STATE_TERMINATED; } } + pong_failures = 0; break; default: /* event received */ @@ -446,6 +456,7 @@ static void loop(const char *iface, const char *ctrlpath, const int disconnect_t /* we are not interested in this event */ break; } + pong_failures = 0; } }