+static void wpas_ctrl_sock_debug(const char *title, int sock, const char *buf,
+ size_t len)
+{
+#ifdef __linux__
+ socklen_t optlen;
+ int sndbuf, outq;
+ int level = MSG_DEBUG;
+
+ if (len >= 5 && os_strncmp(buf, "PONG\n", 5) == 0)
+ level = MSG_EXCESSIVE;
+
+ optlen = sizeof(sndbuf);
+ sndbuf = 0;
+ if (getsockopt(sock, SOL_SOCKET, SO_SNDBUF, &sndbuf, &optlen) < 0)
+ sndbuf = -1;
+
+ if (ioctl(sock, SIOCOUTQ, &outq) < 0)
+ outq = -1;
+
+ wpa_printf(level,
+ "CTRL-DEBUG: %s: sock=%d sndbuf=%d outq=%d send_len=%d",
+ title, sock, sndbuf, outq, (int) len);
+#endif /* __linux__ */
+}
+
+