aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2009-11-14 23:11:28 (GMT)
committerJouni Malinen <j@w1.fi>2009-11-22 19:30:26 (GMT)
commit13aabf1498372b487f5df5ec7dc5fb7c521b4217 (patch)
treee432030205992c33e366c959848e71852515c812 /src
parent7195b6d61ab155b9f3c8da99f4902ee20ec78123 (diff)
downloadhostap-06-13aabf1498372b487f5df5ec7dc5fb7c521b4217.zip
hostap-06-13aabf1498372b487f5df5ec7dc5fb7c521b4217.tar.gz
hostap-06-13aabf1498372b487f5df5ec7dc5fb7c521b4217.tar.bz2
WPS: Use a dummy WSC_ACK as WLANEvent as the initial event if needed
UPnP device architecture specification requires all evented variables to be included in the initial event message after subscription. Since this can happen before we have seen any events, generated a dummy event (WSC_ACK with all-zeros nonces) if needed. (cherry picked from commit fcac668faa5459c3f4ad1f9837f4b0f50edc4cba)
Diffstat (limited to 'src')
-rw-r--r--src/wps/wps_upnp.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/wps/wps_upnp.c b/src/wps/wps_upnp.c
index 2914294..1caa29b 100644
--- a/src/wps/wps_upnp.c
+++ b/src/wps/wps_upnp.c
@@ -47,9 +47,6 @@
* -- Needs renaming with module prefix to avoid polluting the debugger
* namespace and causing possible collisions with other static fncs
* and structure declarations when using the debugger.
- * -- Just what should be in the first event message sent after subscription
- * for the WLANEvent field? If i pass it empty, Vista replies with OK
- * but apparently barfs on the message.
* -- The http error code generation is pretty bogus, hopefully noone cares.
*
* Author: Ted Merrill, Atheros Communications, based upon earlier work
@@ -641,6 +638,27 @@ struct subscription * subscription_find(struct upnp_wps_device_sm *sm,
}
+static struct wpabuf * build_fake_wsc_ack(void)
+{
+ struct wpabuf *msg = wpabuf_alloc(100);
+ if (msg == NULL)
+ return NULL;
+ wpabuf_put_u8(msg, UPNP_WPS_WLANEVENT_TYPE_EAP);
+ wpabuf_put_str(msg, "00:00:00:00:00:00");
+ wps_build_version(msg);
+ wps_build_msg_type(msg, WPS_WSC_ACK);
+ /* Enrollee Nonce */
+ wpabuf_put_be16(msg, ATTR_ENROLLEE_NONCE);
+ wpabuf_put_be16(msg, WPS_NONCE_LEN);
+ wpabuf_put(msg, WPS_NONCE_LEN);
+ /* Registrar Nonce */
+ wpabuf_put_be16(msg, ATTR_REGISTRAR_NONCE);
+ wpabuf_put_be16(msg, WPS_NONCE_LEN);
+ wpabuf_put(msg, WPS_NONCE_LEN);
+ return msg;
+}
+
+
/* subscription_first_event -- send format/queue event that is automatically
* sent on a new subscription.
*/
@@ -665,6 +683,28 @@ static int subscription_first_event(struct subscription *s)
const char *tail = "</e:propertyset>\n";
char txt[10];
+ if (s->sm->wlanevent == NULL) {
+ /*
+ * There has been no events before the subscription. However,
+ * UPnP device architecture specification requires all the
+ * evented variables to be included, so generate a dummy event
+ * for this particular case using a WSC_ACK and all-zeros
+ * nonces. The ER (UPnP control point) will ignore this, but at
+ * least it will learn that WLANEvent variable will be used in
+ * event notifications in the future.
+ */
+ struct wpabuf *msg;
+ wpa_printf(MSG_DEBUG, "WPS UPnP: Use a fake WSC_ACK as the "
+ "initial WLANEvent");
+ msg = build_fake_wsc_ack();
+ if (msg) {
+ s->sm->wlanevent = (char *)
+ base64_encode(wpabuf_head(msg),
+ wpabuf_len(msg), NULL);
+ wpabuf_free(msg);
+ }
+ }
+
wlan_event = s->sm->wlanevent;
if (wlan_event == NULL || *wlan_event == '\0') {
wpa_printf(MSG_DEBUG, "WPS UPnP: WLANEvent not known for "