Browse Source

WPS ER: Add more debug info on initialization errors

Jouni Malinen 14 years ago
parent
commit
6d1031b971
3 changed files with 22 additions and 5 deletions
  1. 2 0
      src/wps/wps_er.c
  2. 12 3
      src/wps/wps_er_ssdp.c
  3. 8 2
      src/wps/wps_upnp_ssdp.c

+ 2 - 0
src/wps/wps_er.c

@@ -1195,6 +1195,7 @@ wps_er_init(struct wps_context *wps, const char *ifname, const char *filter)
 	}
 
 	if (wps_er_ssdp_init(er) < 0) {
+		wpa_printf(MSG_INFO, "WPS UPnP: SSDP initialization failed");
 		wps_er_deinit(er, NULL, NULL);
 		return NULL;
 	}
@@ -1202,6 +1203,7 @@ wps_er_init(struct wps_context *wps, const char *ifname, const char *filter)
 	addr.s_addr = er->ip_addr;
 	er->http_srv = http_server_init(&addr, -1, wps_er_http_req, er);
 	if (er->http_srv == NULL) {
+		wpa_printf(MSG_INFO, "WPS UPnP: HTTP initialization failed");
 		wps_er_deinit(er, NULL, NULL);
 		return NULL;
 	}

+ 12 - 3
src/wps/wps_er_ssdp.c

@@ -165,16 +165,25 @@ void wps_er_send_ssdp_msearch(struct wps_er *er)
 
 int wps_er_ssdp_init(struct wps_er *er)
 {
-	if (add_ssdp_network(er->ifname))
+	if (add_ssdp_network(er->ifname)) {
+		wpa_printf(MSG_INFO, "WPS ER: Failed to add routing entry for "
+			   "SSDP");
 		return -1;
+	}
 
 	er->multicast_sd = ssdp_open_multicast_sock(er->ip_addr);
-	if (er->multicast_sd < 0)
+	if (er->multicast_sd < 0) {
+		wpa_printf(MSG_INFO, "WPS ER: Failed to open multicast socket "
+			   "for SSDP");
 		return -1;
+	}
 
 	er->ssdp_sd = ssdp_listener_open();
-	if (er->ssdp_sd < 0)
+	if (er->ssdp_sd < 0) {
+		wpa_printf(MSG_INFO, "WPS ER: Failed to open SSDP listener "
+			   "socket");
 		return -1;
+	}
 
 	if (eloop_register_sock(er->multicast_sd, EVENT_TYPE_READ,
 				wps_er_ssdp_rx, er, NULL) ||

+ 8 - 2
src/wps/wps_upnp_ssdp.c

@@ -875,11 +875,17 @@ int ssdp_open_multicast_sock(u32 ip_addr)
 #endif
 
 	if (setsockopt(sd, IPPROTO_IP, IP_MULTICAST_IF,
-		       &ip_addr, sizeof(ip_addr)))
+		       &ip_addr, sizeof(ip_addr))) {
+		wpa_printf(MSG_DEBUG, "WPS: setsockopt(IP_MULTICAST_IF) %x: "
+			   "%d (%s)", ip_addr, errno, strerror(errno));
 		return -1;
+	}
 	if (setsockopt(sd, IPPROTO_IP, IP_MULTICAST_TTL,
-		       &ttl, sizeof(ttl)))
+		       &ttl, sizeof(ttl))) {
+		wpa_printf(MSG_DEBUG, "WPS: setsockopt(IP_MULTICAST_TTL): "
+			   "%d (%s)", errno, strerror(errno));
 		return -1;
+	}
 
 #if 0   /* not needed, because we don't receive using multicast_sd */
 	{