This separates the control interface specific generation of a text event message away from the main implementation of USD and makes it more convenient to add support for other control interface mechanisms like dbus. Signed-off-by: Lo,Chin-Ran <chin-ran.lo@xxxxxxx> --- Changelog since v6: * Separate dbus parameters as its individual type * Add the missing method, nan-update-publish * Add the missing signal parameters: FSD, FSD-GAS * Add the NANReplied event. * Add the information to doc/dbus.doxygen wpa_supplicant/nan_usd.c | 65 ++++-------------------- wpa_supplicant/notify.c | 104 +++++++++++++++++++++++++++++++++++++++ wpa_supplicant/notify.h | 23 +++++++++ 3 files changed, 137 insertions(+), 55 deletions(-) diff --git a/wpa_supplicant/nan_usd.c b/wpa_supplicant/nan_usd.c index 657b302c1..6efc70fa7 100644 --- a/wpa_supplicant/nan_usd.c +++ b/wpa_supplicant/nan_usd.c @@ -13,6 +13,7 @@ #include "wpa_supplicant_i.h" #include "offchannel.h" #include "driver_i.h" +#include "notify.h" #include "nan_usd.h" @@ -241,19 +242,10 @@ wpas_nan_de_discovery_result(void *ctx, int subscribe_id, const u8 *peer_addr, bool fsd, bool fsd_gas) { struct wpa_supplicant *wpa_s = ctx; - char *ssi_hex; - ssi_hex = os_zalloc(2 * ssi_len + 1); - if (!ssi_hex) - return; - if (ssi) - wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len); - wpa_msg(wpa_s, MSG_INFO, NAN_DISCOVERY_RESULT - "subscribe_id=%d publish_id=%d address=" MACSTR - " fsd=%d fsd_gas=%d srv_proto_type=%u ssi=%s", - subscribe_id, peer_publish_id, MAC2STR(peer_addr), - fsd, fsd_gas, srv_proto_type, ssi_hex); - os_free(ssi_hex); + wpas_notify_nan_discovery_result(wpa_s, srv_proto_type, subscribe_id, + peer_publish_id, peer_addr, fsd, + fsd_gas, ssi, ssi_len); } @@ -263,34 +255,9 @@ static void wpas_nan_de_replied(void *ctx, int publish_id, const u8 *peer_addr, const u8 *ssi, size_t ssi_len) { struct wpa_supplicant *wpa_s = ctx; - char *ssi_hex; - ssi_hex = os_zalloc(2 * ssi_len + 1); - if (!ssi_hex) - return; - if (ssi) - wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len); - wpa_msg(wpa_s, MSG_INFO, NAN_REPLIED - "publish_id=%d address=" MACSTR - " subscribe_id=%d srv_proto_type=%u ssi=%s", - publish_id, MAC2STR(peer_addr), peer_subscribe_id, - srv_proto_type, ssi_hex); - os_free(ssi_hex); -} - - -static const char * nan_reason_txt(enum nan_de_reason reason) -{ - switch (reason) { - case NAN_DE_REASON_TIMEOUT: - return "timeout"; - case NAN_DE_REASON_USER_REQUEST: - return "user-request"; - case NAN_DE_REASON_FAILURE: - return "failure"; - } - - return "unknown"; + wpas_notify_nan_replied(wpa_s, srv_proto_type, publish_id, + peer_subscribe_id, peer_addr, ssi, ssi_len); } @@ -299,9 +266,7 @@ static void wpas_nan_de_publish_terminated(void *ctx, int publish_id, { struct wpa_supplicant *wpa_s = ctx; - wpa_msg(wpa_s, MSG_INFO, NAN_PUBLISH_TERMINATED - "publish_id=%d reason=%s", - publish_id, nan_reason_txt(reason)); + wpas_notify_nan_publish_terminated(wpa_s, publish_id, reason); } @@ -310,9 +275,7 @@ static void wpas_nan_de_subscribe_terminated(void *ctx, int subscribe_id, { struct wpa_supplicant *wpa_s = ctx; - wpa_msg(wpa_s, MSG_INFO, NAN_SUBSCRIBE_TERMINATED - "subscribe_id=%d reason=%s", - subscribe_id, nan_reason_txt(reason)); + wpas_notify_nan_subscribe_terminated(wpa_s, subscribe_id, reason); } @@ -321,17 +284,9 @@ static void wpas_nan_de_receive(void *ctx, int id, int peer_instance_id, const u8 *peer_addr) { struct wpa_supplicant *wpa_s = ctx; - char *ssi_hex; - ssi_hex = os_zalloc(2 * ssi_len + 1); - if (!ssi_hex) - return; - if (ssi) - wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len); - wpa_msg(wpa_s, MSG_INFO, NAN_RECEIVE - "id=%d peer_instance_id=%d address=" MACSTR " ssi=%s", - id, peer_instance_id, MAC2STR(peer_addr), ssi_hex); - os_free(ssi_hex); + wpas_notify_nan_receive(wpa_s, id, peer_instance_id, peer_addr, + ssi, ssi_len); } diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index 745234dda..7a1222f37 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -10,6 +10,7 @@ #include "utils/common.h" #include "common/wpa_ctrl.h" +#include "common/nan_de.h" #include "config.h" #include "wpa_supplicant_i.h" #include "wps_supplicant.h" @@ -1036,3 +1037,106 @@ void wpas_notify_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s, wpas_dbus_signal_hs20_t_c_acceptance(wpa_s, url); } #endif /* CONFIG_HS20 */ + + +#ifdef CONFIG_NAN_USD + +void wpas_notify_nan_discovery_result(struct wpa_supplicant *wpa_s, + enum nan_service_protocol_type + srv_proto_type, + int subscribe_id, int peer_publish_id, + const u8 *peer_addr, + bool fsd, bool fsd_gas, + const u8 *ssi, size_t ssi_len) +{ + char *ssi_hex; + + ssi_hex = os_zalloc(2 * ssi_len + 1); + if (!ssi_hex) + return; + if (ssi) + wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len); + wpa_msg(wpa_s, MSG_INFO, NAN_DISCOVERY_RESULT + "subscribe_id=%d publish_id=%d address=" MACSTR + " fsd=%d fsd_gas=%d srv_proto_type=%u ssi=%s", + subscribe_id, peer_publish_id, MAC2STR(peer_addr), + fsd, fsd_gas, srv_proto_type, ssi_hex); + os_free(ssi_hex); +} + + +void wpas_notify_nan_replied(struct wpa_supplicant *wpa_s, + enum nan_service_protocol_type srv_proto_type, + int publish_id, int peer_subscribe_id, + const u8 *peer_addr, + const u8 *ssi, size_t ssi_len) +{ + char *ssi_hex; + + ssi_hex = os_zalloc(2 * ssi_len + 1); + if (!ssi_hex) + return; + if (ssi) + wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len); + wpa_msg(wpa_s, MSG_INFO, NAN_REPLIED + "publish_id=%d address=" MACSTR + " subscribe_id=%d srv_proto_type=%u ssi=%s", + publish_id, MAC2STR(peer_addr), peer_subscribe_id, + srv_proto_type, ssi_hex); + os_free(ssi_hex); +} + + +void wpas_notify_nan_receive(struct wpa_supplicant *wpa_s, int id, + int peer_instance_id, const u8 *peer_addr, + const u8 *ssi, size_t ssi_len) +{ + char *ssi_hex; + + ssi_hex = os_zalloc(2 * ssi_len + 1); + if (!ssi_hex) + return; + if (ssi) + wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len); + wpa_msg(wpa_s, MSG_INFO, NAN_RECEIVE + "id=%d peer_instance_id=%d address=" MACSTR " ssi=%s", + id, peer_instance_id, MAC2STR(peer_addr), ssi_hex); + os_free(ssi_hex); +} + + +static const char * nan_reason_txt(enum nan_de_reason reason) +{ + switch (reason) { + case NAN_DE_REASON_TIMEOUT: + return "timeout"; + case NAN_DE_REASON_USER_REQUEST: + return "user-request"; + case NAN_DE_REASON_FAILURE: + return "failure"; + } + + return "unknown"; +} + + +void wpas_notify_nan_publish_terminated(struct wpa_supplicant *wpa_s, + int publish_id, + enum nan_de_reason reason) +{ + wpa_msg(wpa_s, MSG_INFO, NAN_PUBLISH_TERMINATED + "publish_id=%d reason=%s", + publish_id, nan_reason_txt(reason)); +} + + +void wpas_notify_nan_subscribe_terminated(struct wpa_supplicant *wpa_s, + int subscribe_id, + enum nan_de_reason reason) +{ + wpa_msg(wpa_s, MSG_INFO, NAN_SUBSCRIBE_TERMINATED + "subscribe_id=%d reason=%s", + subscribe_id, nan_reason_txt(reason)); +} + +#endif /* CONFIG_NAN_USD */ diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h index 2a0cf097a..31463c15c 100644 --- a/wpa_supplicant/notify.h +++ b/wpa_supplicant/notify.h @@ -17,6 +17,8 @@ struct wps_event_fail; struct tls_cert_data; struct wpa_cred; struct rsn_pmksa_cache_entry; +enum nan_de_reason; +enum nan_service_protocol_type; int wpas_notify_supplicant_initialized(struct wpa_global *global); void wpas_notify_supplicant_deinitialized(struct wpa_global *global); @@ -171,5 +173,26 @@ void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s, void wpas_notify_signal_change(struct wpa_supplicant *wpa_s); void wpas_notify_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s, const char *url); +void wpas_notify_nan_discovery_result(struct wpa_supplicant *wpa_s, + enum nan_service_protocol_type + srv_proto_type, + int subscribe_id, int peer_publish_id, + const u8 *peer_addr, + bool fsd, bool fsd_gas, + const u8 *ssi, size_t ssi_len); +void wpas_notify_nan_replied(struct wpa_supplicant *wpa_s, + enum nan_service_protocol_type srv_proto_type, + int publish_id, int peer_subscribe_id, + const u8 *peer_addr, + const u8 *ssi, size_t ssi_len); +void wpas_notify_nan_receive(struct wpa_supplicant *wpa_s, int id, + int peer_instance_id, const u8 *peer_addr, + const u8 *ssi, size_t ssi_len); +void wpas_notify_nan_publish_terminated(struct wpa_supplicant *wpa_s, + int publish_id, + enum nan_de_reason reason); +void wpas_notify_nan_subscribe_terminated(struct wpa_supplicant *wpa_s, + int subscribe_id, + enum nan_de_reason reason); #endif /* NOTIFY_H */ -- 2.21.0.windows.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap