From 4ea4bb7d82413e20730bbf3cc03c4d8bf8102a7a Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 8 May 2014 12:24:19 +0200 Subject: [PATCH] wifi: parse P2P_DEVICE_FOUND immediately If we delay device-parsing until P2P_PEER returns, we might receive other device events in between which we cannot handle as the peer is unknown. Avoid that by immediately creating the peer and appending more detailed data later once P2P_PEER returns. As P2P_PEER keys and P2P_DEVICE_FOUND keys are different (wholy shit, what a fucking interface), we need to parse both. Lets hope there won't be any conflicts. WARNING: The wfd_subelements field is currently very inconsistent. Sometimes we only use dev_info fields, somethings the whole IE. Users shall use it as boolean value, only (set vs. unset). Once we add a proper IE parser, we will provide more advanced fields. Signed-off-by: David Herrmann --- src/wifi/wifid-supplicant.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/wifi/wifid-supplicant.c b/src/wifi/wifid-supplicant.c index bb79e2a..898abf1 100644 --- a/src/wifi/wifid-supplicant.c +++ b/src/wifi/wifid-supplicant.c @@ -832,6 +832,23 @@ static void supplicant_parse_peer(struct supplicant *s, sp->wfd_subelements = t; peer_supplicant_wfd_subelements_changed(sp->p); } + } else { + /* TODO: wfd_dev_info only contains the dev-info sub-elem, + * while wfd_sublemens contains all. Fix that! The user has no + * chance to distinguish both. + * We currently use it only as boolen (set/unset) but once we + * parse it we _definitely_ have to provide proper data. */ + r = wpas_message_dict_read(m, "wfd_dev_info", 's', &val); + if (r >= 0) { + t = strdup(val); + if (!t) { + log_vENOMEM(); + } else { + free(sp->wfd_subelements); + sp->wfd_subelements = t; + peer_supplicant_wfd_subelements_changed(sp->p); + } + } } if (s->running) @@ -871,7 +888,7 @@ static void supplicant_event_p2p_device_found(struct supplicant *s, /* * The P2P-DEVICE-FOUND event is quite small. Request a full - * peer-report and only use the peer once it returns. + * peer-report. */ r = wpas_message_dict_read(ev, "p2p_dev_addr", 's', &mac); @@ -881,6 +898,8 @@ static void supplicant_event_p2p_device_found(struct supplicant *s, return; } + supplicant_parse_peer(s, ev); + r = wpas_message_new_request(s->bus_global, "P2P_PEER", &m);