aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-11-14 22:46:58 (GMT)
committerJouni Malinen <j@w1.fi>2009-11-22 19:30:05 (GMT)
commit7195b6d61ab155b9f3c8da99f4902ee20ec78123 (patch)
tree9698e0af920972ce3dc5eb27385bf03f8db50f7b /src
parentb6fd1b09565cc316a7708f35da746c4b27ee42c2 (diff)
downloadhostap-06-7195b6d61ab155b9f3c8da99f4902ee20ec78123.zip
hostap-06-7195b6d61ab155b9f3c8da99f4902ee20ec78123.tar.gz
hostap-06-7195b6d61ab155b9f3c8da99f4902ee20ec78123.tar.bz2
WPS: Send SSDP byebye notifications when stopping UPnP advertisements
This will notify control points of the services going away and allows them to notice this without having to wait timeout on the initial advertisements. (cherry picked from commit 44577e4c2e37b1039ec8850c61e7a71f6c242c1f)
Diffstat (limited to 'src')
-rw-r--r--src/wps/wps_upnp.c3
-rw-r--r--src/wps/wps_upnp_i.h3
-rw-r--r--src/wps/wps_upnp_ssdp.c35
3 files changed, 36 insertions, 5 deletions
diff --git a/src/wps/wps_upnp.c b/src/wps/wps_upnp.c
index da488bc..2914294 100644
--- a/src/wps/wps_upnp.c
+++ b/src/wps/wps_upnp.c
@@ -967,8 +967,7 @@ void upnp_wps_device_stop(struct upnp_wps_device_sm *sm)
subscription_destroy(s);
}
- advertisement_state_machine_stop(sm);
- /* TODO: send byebye notifications */
+ advertisement_state_machine_stop(sm, 1);
event_send_stop_all(sm);
os_free(sm->wlanevent);
diff --git a/src/wps/wps_upnp_i.h b/src/wps/wps_upnp_i.h
index edaa16d..6a4aa5e 100644
--- a/src/wps/wps_upnp_i.h
+++ b/src/wps/wps_upnp_i.h
@@ -172,7 +172,8 @@ int send_wpabuf(int fd, struct wpabuf *buf);
/* wps_upnp_ssdp.c */
void msearchreply_state_machine_stop(struct advertisement_state_machine *a);
int advertisement_state_machine_start(struct upnp_wps_device_sm *sm);
-void advertisement_state_machine_stop(struct upnp_wps_device_sm *sm);
+void advertisement_state_machine_stop(struct upnp_wps_device_sm *sm,
+ int send_byebye);
void ssdp_listener_stop(struct upnp_wps_device_sm *sm);
int ssdp_listener_start(struct upnp_wps_device_sm *sm);
int add_ssdp_network(char *net_if);
diff --git a/src/wps/wps_upnp_ssdp.c b/src/wps/wps_upnp_ssdp.c
index 92b785c..b594e20 100644
--- a/src/wps/wps_upnp_ssdp.c
+++ b/src/wps/wps_upnp_ssdp.c
@@ -229,10 +229,41 @@ static void advertisement_state_machine_handler(void *eloop_data,
/**
* advertisement_state_machine_stop - Stop SSDP advertisements
* @sm: WPS UPnP state machine from upnp_wps_device_init()
+ * @send_byebye: Send byebye advertisement messages immediately
*/
-void advertisement_state_machine_stop(struct upnp_wps_device_sm *sm)
+void advertisement_state_machine_stop(struct upnp_wps_device_sm *sm,
+ int send_byebye)
{
+ struct advertisement_state_machine *a = &sm->advertisement;
+ int islast = 0;
+ struct wpabuf *msg;
+ struct sockaddr_in dest;
+
eloop_cancel_timeout(advertisement_state_machine_handler, NULL, sm);
+ if (!send_byebye)
+ return;
+
+ a->type = ADVERTISE_DOWN;
+ a->state = 0;
+ a->sm = sm;
+
+ os_memset(&dest, 0, sizeof(dest));
+ dest.sin_family = AF_INET;
+ dest.sin_addr.s_addr = inet_addr(UPNP_MULTICAST_ADDRESS);
+ dest.sin_port = htons(UPNP_MULTICAST_PORT);
+
+ while (!islast) {
+ msg = next_advertisement(a, &islast);
+ if (msg == NULL)
+ break;
+ if (sendto(sm->multicast_sd, wpabuf_head(msg), wpabuf_len(msg),
+ 0, (struct sockaddr *) &dest, sizeof(dest)) < 0) {
+ wpa_printf(MSG_INFO, "WPS UPnP: Advertisement sendto "
+ "failed: %d (%s)", errno, strerror(errno));
+ }
+ wpabuf_free(msg);
+ a->state++;
+ }
}
@@ -318,7 +349,7 @@ int advertisement_state_machine_start(struct upnp_wps_device_sm *sm)
struct advertisement_state_machine *a = &sm->advertisement;
int next_timeout_msec;
- advertisement_state_machine_stop(sm);
+ advertisement_state_machine_stop(sm, 0);
/*
* Start out advertising down, this automatically switches