From: Jouni Malinen Date: Wed, 11 Sep 2013 03:17:07 +0000 (-0700) Subject: Print ctrl_iface sendto() failures into debug log X-Git-Tag: hostap_2_1~941 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79986bf69ea592118ee52c6934dc150bb3611e2e;p=thirdparty%2Fhostap.git Print ctrl_iface sendto() failures into debug log This makes it easier to debug issues with control interface operations failing. Signed-hostap: Jouni Malinen --- diff --git a/wpa_supplicant/ctrl_iface_unix.c b/wpa_supplicant/ctrl_iface_unix.c index e35d2c396..49489d6f8 100644 --- a/wpa_supplicant/ctrl_iface_unix.c +++ b/wpa_supplicant/ctrl_iface_unix.c @@ -182,15 +182,27 @@ static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx, } if (reply) { - sendto(sock, reply, reply_len, 0, (struct sockaddr *) &from, - fromlen); + if (sendto(sock, reply, reply_len, 0, (struct sockaddr *) &from, + fromlen) < 0) { + wpa_dbg(wpa_s, MSG_DEBUG, + "ctrl_iface sendto failed: %s", + strerror(errno)); + } os_free(reply); } else if (reply_len == 1) { - sendto(sock, "FAIL\n", 5, 0, (struct sockaddr *) &from, - fromlen); + if (sendto(sock, "FAIL\n", 5, 0, (struct sockaddr *) &from, + fromlen) < 0) { + wpa_dbg(wpa_s, MSG_DEBUG, + "ctrl_iface sendto failed: %s", + strerror(errno)); + } } else if (reply_len == 2) { - sendto(sock, "OK\n", 3, 0, (struct sockaddr *) &from, - fromlen); + if (sendto(sock, "OK\n", 3, 0, (struct sockaddr *) &from, + fromlen) < 0) { + wpa_dbg(wpa_s, MSG_DEBUG, + "ctrl_iface sendto failed: %s", + strerror(errno)); + } } if (new_attached) @@ -656,18 +668,30 @@ void wpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv) /* handle ATTACH signal of first monitor interface */ if (!wpa_supplicant_ctrl_iface_attach(&priv->ctrl_dst, &from, fromlen)) { - sendto(priv->sock, "OK\n", 3, 0, - (struct sockaddr *) &from, fromlen); + if (sendto(priv->sock, "OK\n", 3, 0, + (struct sockaddr *) &from, fromlen) < + 0) { + wpa_printf(MSG_DEBUG, "ctrl_iface sendto failed: %s", + strerror(errno)); + } /* OK to continue */ return; } else { - sendto(priv->sock, "FAIL\n", 5, 0, - (struct sockaddr *) &from, fromlen); + if (sendto(priv->sock, "FAIL\n", 5, 0, + (struct sockaddr *) &from, fromlen) < + 0) { + wpa_printf(MSG_DEBUG, "ctrl_iface sendto failed: %s", + strerror(errno)); + } } } else { /* return FAIL for all other signals */ - sendto(priv->sock, "FAIL\n", 5, 0, - (struct sockaddr *) &from, fromlen); + if (sendto(priv->sock, "FAIL\n", 5, 0, + (struct sockaddr *) &from, fromlen) < 0) { + wpa_printf(MSG_DEBUG, + "ctrl_iface sendto failed: %s", + strerror(errno)); + } } } } @@ -714,14 +738,24 @@ static void wpa_supplicant_global_ctrl_iface_receive(int sock, void *eloop_ctx, } if (reply) { - sendto(sock, reply, reply_len, 0, (struct sockaddr *) &from, - fromlen); + if (sendto(sock, reply, reply_len, 0, (struct sockaddr *) &from, + fromlen) < 0) { + wpa_printf(MSG_DEBUG, "ctrl_iface sendto failed: %s", + strerror(errno)); + } os_free(reply); } else if (reply_len == 1) { - sendto(sock, "FAIL\n", 5, 0, (struct sockaddr *) &from, - fromlen); + if (sendto(sock, "FAIL\n", 5, 0, (struct sockaddr *) &from, + fromlen) < 0) { + wpa_printf(MSG_DEBUG, "ctrl_iface sendto failed: %s", + strerror(errno)); + } } else if (reply_len == 2) { - sendto(sock, "OK\n", 3, 0, (struct sockaddr *) &from, fromlen); + if (sendto(sock, "OK\n", 3, 0, (struct sockaddr *) &from, + fromlen) < 0) { + wpa_printf(MSG_DEBUG, "ctrl_iface sendto failed: %s", + strerror(errno)); + } } }