mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-30 16:54:04 -05:00
WPS UPnP: Add IP address and port details into debug messages
This makes it much easier to debug operations with multiple external Registrars.
This commit is contained in:
parent
e1bad1cd7d
commit
745f8b664d
@ -465,7 +465,7 @@ static void subscr_addr_list_create(struct subscription *s,
|
|||||||
|
|
||||||
int send_wpabuf(int fd, struct wpabuf *buf)
|
int send_wpabuf(int fd, struct wpabuf *buf)
|
||||||
{
|
{
|
||||||
wpa_printf(MSG_DEBUG, "WPS UPnP: %lu byte response",
|
wpa_printf(MSG_DEBUG, "WPS UPnP: Send %lu byte message",
|
||||||
(unsigned long) wpabuf_len(buf));
|
(unsigned long) wpabuf_len(buf));
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (write(fd, wpabuf_head(buf), wpabuf_len(buf)) !=
|
if (write(fd, wpabuf_head(buf), wpabuf_len(buf)) !=
|
||||||
|
@ -187,7 +187,8 @@ static void event_retry(struct wps_event_ *e, int do_next_address)
|
|||||||
if (do_next_address)
|
if (do_next_address)
|
||||||
e->retry++;
|
e->retry++;
|
||||||
if (e->retry >= s->n_addr) {
|
if (e->retry >= s->n_addr) {
|
||||||
wpa_printf(MSG_DEBUG, "WPS UPnP: Giving up on sending event");
|
wpa_printf(MSG_DEBUG, "WPS UPnP: Giving up on sending event "
|
||||||
|
"for %s", e->addr->domain_and_port);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event_enqueue_at_begin(s, e);
|
event_enqueue_at_begin(s, e);
|
||||||
@ -226,20 +227,25 @@ static void event_got_response_handler(struct httpread *handle, void *cookie,
|
|||||||
reply_code = httpread_reply_code_get(hread);
|
reply_code = httpread_reply_code_get(hread);
|
||||||
if (reply_code == HTTP_OK) {
|
if (reply_code == HTTP_OK) {
|
||||||
wpa_printf(MSG_DEBUG,
|
wpa_printf(MSG_DEBUG,
|
||||||
"WPS UPnP: Got event reply OK");
|
"WPS UPnP: Got event reply OK from "
|
||||||
|
"%s", e->addr->domain_and_port);
|
||||||
event_delete(e);
|
event_delete(e);
|
||||||
goto send_more;
|
goto send_more;
|
||||||
} else {
|
} else {
|
||||||
wpa_printf(MSG_DEBUG, "WPS UPnP: Got event "
|
wpa_printf(MSG_DEBUG, "WPS UPnP: Got event "
|
||||||
"error reply code %d", reply_code);
|
"error reply code %d from %s",
|
||||||
|
reply_code,
|
||||||
|
e->addr->domain_and_port);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wpa_printf(MSG_DEBUG, "WPS UPnP: Got bogus event "
|
wpa_printf(MSG_DEBUG, "WPS UPnP: Got bogus event "
|
||||||
"response %d", en);
|
"response %d from %s", en,
|
||||||
|
e->addr->domain_and_port);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wpa_printf(MSG_DEBUG, "WPS UPnP: Event response timeout/fail");
|
wpa_printf(MSG_DEBUG, "WPS UPnP: Event response timeout/fail "
|
||||||
|
"for %s", e->addr->domain_and_port);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
event_retry(e, 1);
|
event_retry(e, 1);
|
||||||
@ -313,6 +319,8 @@ static void event_send_tx_ready(int sock, void *eloop_ctx, void *sock_ctx)
|
|||||||
/* we could: Turn blocking back on? */
|
/* we could: Turn blocking back on? */
|
||||||
fcntl(e->sd, F_SETFL, 0);
|
fcntl(e->sd, F_SETFL, 0);
|
||||||
#endif
|
#endif
|
||||||
|
wpa_printf(MSG_DEBUG, "WPS UPnP: Sending event to %s",
|
||||||
|
e->addr->domain_and_port);
|
||||||
if (send_wpabuf(e->sd, buf) < 0) {
|
if (send_wpabuf(e->sd, buf) < 0) {
|
||||||
event_retry(e, 1);
|
event_retry(e, 1);
|
||||||
goto bad;
|
goto bad;
|
||||||
|
@ -51,6 +51,7 @@ struct web_connection {
|
|||||||
struct web_connection *prev;
|
struct web_connection *prev;
|
||||||
struct upnp_wps_device_sm *sm; /* parent */
|
struct upnp_wps_device_sm *sm; /* parent */
|
||||||
int sd; /* socket to read from */
|
int sd; /* socket to read from */
|
||||||
|
struct sockaddr_in cli_addr;
|
||||||
int sd_registered; /* nonzero if we must cancel registration */
|
int sd_registered; /* nonzero if we must cancel registration */
|
||||||
struct httpread *hread; /* state machine for reading socket */
|
struct httpread *hread; /* state machine for reading socket */
|
||||||
int n_rcvd_data; /* how much data read so far */
|
int n_rcvd_data; /* how much data read so far */
|
||||||
@ -689,6 +690,7 @@ static void web_connection_parse_get(struct web_connection *c, char *filename)
|
|||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
filename = "(null)"; /* just in case */
|
filename = "(null)"; /* just in case */
|
||||||
if (os_strcasecmp(filename, UPNP_WPS_DEVICE_XML_FILE) == 0) {
|
if (os_strcasecmp(filename, UPNP_WPS_DEVICE_XML_FILE) == 0) {
|
||||||
|
wpa_printf(MSG_DEBUG, "WPS UPnP: HTTP GET for device XML");
|
||||||
req = GET_DEVICE_XML_FILE;
|
req = GET_DEVICE_XML_FILE;
|
||||||
extra_len = 3000;
|
extra_len = 3000;
|
||||||
if (sm->wps->friendly_name)
|
if (sm->wps->friendly_name)
|
||||||
@ -702,11 +704,12 @@ static void web_connection_parse_get(struct web_connection *c, char *filename)
|
|||||||
if (sm->wps->upc)
|
if (sm->wps->upc)
|
||||||
extra_len += os_strlen(sm->wps->upc);
|
extra_len += os_strlen(sm->wps->upc);
|
||||||
} else if (!os_strcasecmp(filename, UPNP_WPS_SCPD_XML_FILE)) {
|
} else if (!os_strcasecmp(filename, UPNP_WPS_SCPD_XML_FILE)) {
|
||||||
|
wpa_printf(MSG_DEBUG, "WPS UPnP: HTTP GET for SCPD XML");
|
||||||
req = GET_SCPD_XML_FILE;
|
req = GET_SCPD_XML_FILE;
|
||||||
extra_len = os_strlen(wps_scpd_xml);
|
extra_len = os_strlen(wps_scpd_xml);
|
||||||
} else {
|
} else {
|
||||||
/* File not found */
|
/* File not found */
|
||||||
wpa_printf(MSG_DEBUG, "WPS UPnP: File not found: %s",
|
wpa_printf(MSG_DEBUG, "WPS UPnP: HTTP GET file not found: %s",
|
||||||
filename);
|
filename);
|
||||||
buf = wpabuf_alloc(200);
|
buf = wpabuf_alloc(200);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
@ -1465,6 +1468,7 @@ static void web_connection_parse_subscribe(struct web_connection *c,
|
|||||||
ret = HTTP_PRECONDITION_FAILED;
|
ret = HTTP_PRECONDITION_FAILED;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
wpa_printf(MSG_DEBUG, "WPS UPnP: HTTP SUBSCRIBE for event");
|
||||||
end = os_strchr(h, '\n');
|
end = os_strchr(h, '\n');
|
||||||
|
|
||||||
for (; end != NULL; h = end + 1) {
|
for (; end != NULL; h = end + 1) {
|
||||||
@ -1595,8 +1599,6 @@ static void web_connection_parse_subscribe(struct web_connection *c,
|
|||||||
/* And empty line to terminate header: */
|
/* And empty line to terminate header: */
|
||||||
wpabuf_put_str(buf, "\r\n");
|
wpabuf_put_str(buf, "\r\n");
|
||||||
|
|
||||||
wpa_hexdump_ascii(MSG_MSGDUMP, "WPS UPnP SUBSCRIBE response",
|
|
||||||
wpabuf_head(buf), wpabuf_len(buf));
|
|
||||||
send_wpabuf(c->sd, buf);
|
send_wpabuf(c->sd, buf);
|
||||||
wpabuf_free(buf);
|
wpabuf_free(buf);
|
||||||
os_free(callback_urls);
|
os_free(callback_urls);
|
||||||
@ -1669,6 +1671,7 @@ static void web_connection_parse_unsubscribe(struct web_connection *c,
|
|||||||
ret = HTTP_PRECONDITION_FAILED;
|
ret = HTTP_PRECONDITION_FAILED;
|
||||||
goto send_msg;
|
goto send_msg;
|
||||||
}
|
}
|
||||||
|
wpa_printf(MSG_DEBUG, "WPS UPnP: HTTP UNSUBSCRIBE for event");
|
||||||
end = os_strchr(h, '\n');
|
end = os_strchr(h, '\n');
|
||||||
|
|
||||||
for (; end != NULL; h = end + 1) {
|
for (; end != NULL; h = end + 1) {
|
||||||
@ -1776,7 +1779,9 @@ static void web_connection_check_data(struct web_connection *c)
|
|||||||
while (*filename == '/')
|
while (*filename == '/')
|
||||||
filename++;
|
filename++;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "WPS UPnP: Got HTTP request type %d", htype);
|
wpa_printf(MSG_DEBUG, "WPS UPnP: Got HTTP request type %d from %s:%d",
|
||||||
|
htype, inet_ntoa(c->cli_addr.sin_addr),
|
||||||
|
htons(c->cli_addr.sin_port));
|
||||||
|
|
||||||
switch (htype) {
|
switch (htype) {
|
||||||
case HTTPREAD_HDR_TYPE_GET:
|
case HTTPREAD_HDR_TYPE_GET:
|
||||||
@ -1821,14 +1826,13 @@ static void web_connection_got_file_handler(struct httpread *handle,
|
|||||||
/* web_connection_start - Start web connection
|
/* web_connection_start - Start web connection
|
||||||
* @sm: WPS UPnP state machine from upnp_wps_device_init()
|
* @sm: WPS UPnP state machine from upnp_wps_device_init()
|
||||||
* @sd: Socket descriptor
|
* @sd: Socket descriptor
|
||||||
* @ip_addr: of client, in host byte order
|
* @addr: Client address
|
||||||
* @ip_port: of client, in native byte order
|
|
||||||
*
|
*
|
||||||
* The socket descriptor sd is handed over for ownership by the WPs UPnP
|
* The socket descriptor sd is handed over for ownership by the WPS UPnP
|
||||||
* state machine.
|
* state machine.
|
||||||
*/
|
*/
|
||||||
static void web_connection_start(struct upnp_wps_device_sm *sm,
|
static void web_connection_start(struct upnp_wps_device_sm *sm,
|
||||||
int sd, unsigned ip_addr, unsigned ip_port)
|
int sd, struct sockaddr_in *addr)
|
||||||
{
|
{
|
||||||
struct web_connection *c = NULL;
|
struct web_connection *c = NULL;
|
||||||
|
|
||||||
@ -1841,6 +1845,7 @@ static void web_connection_start(struct upnp_wps_device_sm *sm,
|
|||||||
c = os_zalloc(sizeof(*c));
|
c = os_zalloc(sizeof(*c));
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
return;
|
return;
|
||||||
|
os_memcpy(&c->cli_addr, addr, sizeof(c->cli_addr));
|
||||||
c->sm = sm;
|
c->sm = sm;
|
||||||
c->sd = sd;
|
c->sd = sd;
|
||||||
#if 0
|
#if 0
|
||||||
@ -1908,8 +1913,7 @@ static void web_listener_handler(int sd, void *eloop_ctx, void *sock_ctx)
|
|||||||
errno, strerror(errno), sm->web_sd);
|
errno, strerror(errno), sm->web_sd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
web_connection_start(sm, new_sd, addr.sin_addr.s_addr,
|
web_connection_start(sm, new_sd, &addr);
|
||||||
htons(addr.sin_port));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user