1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-02-13 02:12:09 +00:00

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 <dh.herrmann@gmail.com>
This commit is contained in:
David Herrmann 2014-05-08 12:24:19 +02:00
parent f6e434e86a
commit 4ea4bb7d82

View file

@ -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);