#include "inm-supplicant.h"
#include "inm-supplicant-internal.h"
-static void __handle_scan_done(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_bss_added(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_bss_removed(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_blob_added(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_blob_removed(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_network_added(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_network_removed(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_network_selected(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_sta_authorized(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_sta_deauthorized(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __iface_properties_changed(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_certification(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_eap(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_network_request(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_probe_request(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_wps_event(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
-
-static void __handle_wps_credentials(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data);
+DECLARE_DBUS_SIGNAL_HANDLER(handle_scan_done);
+DECLARE_DBUS_SIGNAL_HANDLER(handle_sta_authorized);
+DECLARE_DBUS_SIGNAL_HANDLER(handle_sta_deauthorized);
+DECLARE_DBUS_SIGNAL_HANDLER(iface_properties_changed);
+DECLARE_DBUS_SIGNAL_HANDLER(handle_wps_event);
+DECLARE_DBUS_SIGNAL_HANDLER(handle_wps_credentials);
+
+static inm_supplicant_iface_changed_callback g_iface_prop_changed_cb;
+static gpointer g_iface_prop_changed_cb_user_data;
+static GHashTable *g_supplicant_iface_tbl = NULL;
static signal_param_s iface_signal_params[] = {
{
.callback = __handle_scan_done,
.subscriber_id = 0,
},
- {
- .sender = SUPPLICANT_SERVICE,
- .interface_name = SUPPLICANT_IFACE_INTERFACE,
- .member = "BSSAdded",
- .object_path = NULL,
- .arg0 = NULL,
- .callback = __handle_bss_added,
- .subscriber_id = 0,
- },
- {
- .sender = SUPPLICANT_SERVICE,
- .interface_name = SUPPLICANT_IFACE_INTERFACE,
- .member = "BSSRemoved",
- .object_path = NULL,
- .arg0 = NULL,
- .callback = __handle_bss_removed,
- .subscriber_id = 0,
- },
- {
- .sender = SUPPLICANT_SERVICE,
- .interface_name = SUPPLICANT_IFACE_INTERFACE,
- .member = "BlobAdded",
- .object_path = NULL,
- .arg0 = NULL,
- .callback = __handle_blob_added,
- .subscriber_id = 0,
- },
- {
- .sender = SUPPLICANT_SERVICE,
- .interface_name = SUPPLICANT_IFACE_INTERFACE,
- .member = "BlobRemoved",
- .object_path = NULL,
- .arg0 = NULL,
- .callback = __handle_blob_removed,
- .subscriber_id = 0,
- },
- {
- .sender = SUPPLICANT_SERVICE,
- .interface_name = SUPPLICANT_IFACE_INTERFACE,
- .member = "NetworkAdded",
- .object_path = NULL,
- .arg0 = NULL,
- .callback = __handle_network_added,
- .subscriber_id = 0,
- },
- {
- .sender = SUPPLICANT_SERVICE,
- .interface_name = SUPPLICANT_IFACE_INTERFACE,
- .member = "NetworkRemoved",
- .object_path = NULL,
- .arg0 = NULL,
- .callback = __handle_network_removed,
- .subscriber_id = 0,
- },
- {
- .sender = SUPPLICANT_SERVICE,
- .interface_name = SUPPLICANT_IFACE_INTERFACE,
- .member = "NetworkSelected",
- .object_path = NULL,
- .arg0 = NULL,
- .callback = __handle_network_selected,
- .subscriber_id = 0,
- },
{
.sender = SUPPLICANT_SERVICE,
.interface_name = SUPPLICANT_IFACE_INTERFACE,
.callback = __iface_properties_changed,
.subscriber_id = 0,
},
- {
- .sender = SUPPLICANT_SERVICE,
- .interface_name = SUPPLICANT_IFACE_INTERFACE,
- .member = "Certification",
- .object_path = NULL,
- .arg0 = NULL,
- .callback = __handle_certification,
- .subscriber_id = 0,
- },
- {
- .sender = SUPPLICANT_SERVICE,
- .interface_name = SUPPLICANT_IFACE_INTERFACE,
- .member = "EAP",
- .object_path = NULL,
- .arg0 = NULL,
- .callback = __handle_eap,
- .subscriber_id = 0,
- },
- {
- .sender = SUPPLICANT_SERVICE,
- .interface_name = SUPPLICANT_IFACE_INTERFACE,
- .member = "NetworkRequest",
- .object_path = NULL,
- .arg0 = NULL,
- .callback = __handle_network_request,
- .subscriber_id = 0,
- },
- {
- .sender = SUPPLICANT_SERVICE,
- .interface_name = SUPPLICANT_IFACE_INTERFACE,
- .member = "ProbeRequest",
- .object_path = NULL,
- .arg0 = NULL,
- .callback = __handle_probe_request,
- .subscriber_id = 0,
- },
{
.sender = SUPPLICANT_SERVICE,
.interface_name = SUPPLICANT_IFACE_WPS,
},
};
-static method_param_s get_iface_property_method_param = {
- .bus_name = SUPPLICANT_SERVICE,
- .object_path = NULL,
- .interface_name = DBUS_PROPERTIES_INTERFACE,
- .method_name = DBUS_PROPERTIES_METHOD_GETALL,
- .parameters = NULL,
-};
-
-static method_param_s signal_poll_method_param = {
- .bus_name = SUPPLICANT_SERVICE,
- .object_path = NULL,
- .interface_name = SUPPLICANT_IFACE_INTERFACE,
- .method_name = "SignalPoll",
- .parameters = NULL,
-};
-
-inm_supplicant_iface_changed_callback g_iface_prop_changed_cb;
-gpointer g_iface_prop_changed_cb_user_data;
-GHashTable *g_supplicant_iface_tbl = NULL;
-
static inline int __subscribe_iface_signal(const gchar *path, inm_supplicant_iface_s *iface_data)
{
int ret = INM_GDBUS_ERROR_NONE;
}
INM_LOGI("path [%s]", path);
- for (signal_idx = IFACE_SIGNAL_SCANDONE; signal_idx < IFACE_SIGNAL_MAX; signal_idx++) {
+ for (signal_idx = IFACE_SIGNAL_SCANDONE; signal_idx < IFACE_SIGNAL_MAX; ++signal_idx) {
iface_signal_params[signal_idx].object_path = path;
ret = inm_gdbus_subscribe_signal(&(iface_signal_params[signal_idx]));
if (ret != INM_GDBUS_ERROR_NONE)
return INM_SUPPLICANT_ERROR_INVALID_PARAM;
}
- for (signal_idx = IFACE_SIGNAL_SCANDONE; signal_idx < IFACE_SIGNAL_PROBEREQUEST; signal_idx++) {
+ for (signal_idx = IFACE_SIGNAL_SCANDONE; signal_idx < IFACE_SIGNAL_MAX; ++signal_idx) {
if (iface_data->subscriber_id[signal_idx] == 0)
continue;
inm_supplicant_iface_s *iface_data = (inm_supplicant_iface_s *)data;
__INM_FUNC_ENTER__;
- g_hash_table_remove_all(iface_data->bss_tbl);
- g_hash_table_unref(iface_data->bss_tbl);
- iface_data->bss_tbl = NULL;
-
__unsubscribe_iface_signal(iface_data);
g_free(iface_data);
g_strlcpy(iface->Ifname, str, IFNAME_MAX + 1);
}
-static inline void __get_iface_current_bss(GVariant *value, inm_supplicant_iface_s *iface)
+static inline void __get_iface_disconnect_reason(GVariant *value, inm_supplicant_iface_s *iface)
{
- const gchar *path = NULL;
- gpointer bss = NULL;
- __INM_FUNC_ENTER__;
-
- g_variant_get(value, "&o", &path);
- if (!path)
- return;
-
- if (g_strcmp0(path, "/") == 0) {
- INM_LOGI("Null path");
- iface->current_bss = NULL;
- return;
- }
-
- bss = g_hash_table_lookup(iface->bss_tbl, path);
- if (bss)
- iface->current_bss = bss;
- else
- iface->current_bss = NULL;
-
- __INM_FUNC_EXIT__;
-}
-
-static inline void __get_iface_bsss(GVariant *value, inm_supplicant_iface_s *iface)
-{
- GVariantIter *iter = NULL;
- const gchar *obj = NULL;
-
- g_variant_get(value, "ao", &iter);
- if (!iter || !iface) {
- INM_LOGW("Invalid params");
- __INM_FUNC_EXIT__;
- return;
- }
-
- while (g_variant_iter_loop(iter, "o", &obj))
- inm_supplicant_bss_add_by_path(obj, iface->bss_tbl);
-
- g_variant_iter_free(iter);
-}
+ int reason;
-static inline void __get_iface_current_network(GVariant *value, inm_supplicant_iface_s *iface)
-{
- const gchar *obj = NULL;
-
- g_variant_get(value, "&o", &obj);
-
- g_free(iface->current_network);
- iface->current_network = NULL;
-
- if (g_strcmp0(obj, "/") == 0) {
- INM_LOGI("Null path");
- return;
- }
-
- inm_supplicant_network_add_by_path(obj, &(iface->current_network));
- return;
+ g_variant_get(value, "i", &reason);
+ PRINT_LOG("<WPA event:Disconnect reason %d>", reason);
}
static inline void __get_iface_property(const gchar *key, GVariant *value, inm_supplicant_iface_s *iface)
__get_iface_scanning(value, iface);
else if (g_strcmp0(key, "Ifname") == 0)
__get_iface_ifname(value, iface);
- else if (g_strcmp0(key, "CurrentBSS") == 0)
- __get_iface_current_bss(value, iface);
- else if (g_strcmp0(key, "BSSs") == 0)
- __get_iface_bsss(value, iface);
- else if (g_strcmp0(key, "CurrentNetwork") == 0)
- __get_iface_current_network(value, iface);
-/*
- else if (g_strcmp0(key, "CurrentAuthMode") == 0)
- __get_iface_current_auth_mode(value, iface);
- else if (g_strcmp0(key, "Blobs") == 0)
- __get_iface_blobs(value, iface);
- else if (g_strcmp0(key, "Networks") == 0)
- __get_iface_networks(value, iface);
-*/
-}
-
-static inline void __get_iface_property_without_bss(const gchar *key, GVariant *value, inm_supplicant_iface_s *iface)
-{
- INM_LOGI("Prop %s", key);
- if (g_strcmp0(key, "Capabilities") == 0)
- __get_iface_capabilities(value, iface);
- else if (g_strcmp0(key, "State") == 0)
- __get_iface_state(value, iface);
- else if (g_strcmp0(key, "Scanning") == 0)
- __get_iface_scanning(value, iface);
- else if (g_strcmp0(key, "Ifname") == 0)
- __get_iface_ifname(value, iface);
- else if (g_strcmp0(key, "CurrentBSS") == 0)
- __get_iface_current_bss(value, iface);
- else if (g_strcmp0(key, "CurrentNetwork") == 0)
- __get_iface_current_network(value, iface);
-/*
- else if (g_strcmp0(key, "CurrentAuthMode") == 0)
- __get_iface_current_auth_mode(value, iface);
- else if (g_strcmp0(key, "Blobs") == 0)
- __get_iface_blobs(value, iface);
- else if (g_strcmp0(key, "Networks") == 0)
- __get_iface_networks(value, iface);
-*/
+ else if (g_strcmp0(key, "DisconnectReason") == 0)
+ __get_iface_disconnect_reason(value, iface);
}
void __get_iface_properties(GVariant *value, gpointer user_data)
return;
}
-void __get_iface_properties_without_bss(GVariant *value, gpointer user_data)
-{
- GVariantIter *iter = NULL;
- const gchar *key = NULL;
- GVariant *var = NULL;
- inm_supplicant_iface_s *iface = NULL;
-
- if (!value || !user_data)
- return;
-
- g_variant_get(value, "(a{sv})", &iter);
- if (!iter) {
- INM_LOGI("null iter!");
- return;
- }
-
- iface = (inm_supplicant_iface_s *)user_data;
- while (g_variant_iter_loop(iter, "{sv}", &key, &var))
- __get_iface_property_without_bss(key, var, iface);
-
- g_variant_iter_free(iter);
-
- return;
-}
-static void __handle_scan_done(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
-{
- __INM_FUNC_ENTER__;
-
- __INM_FUNC_EXIT__;
- return;
-}
-
-static void __handle_bss_added(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
-{
- inm_supplicant_iface_s *iface = NULL;
- GVariantIter *iter = NULL;
- const gchar *path = NULL;
- gint ret = 0;
- __INM_FUNC_ENTER__;
-
- g_variant_get(parameters, "(oa{sv})", &path, &iter);
- if (!path || !iter) {
- __INM_FUNC_EXIT__;
- return;
- }
-
- iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
- if (!iface) {
- __INM_FUNC_EXIT__;
- INM_LOGI("iface not found");
- return;
- }
-
- ret = inm_supplicant_bss_add(path, iter, iface->bss_tbl);
- if (ret < 0) {
- __INM_FUNC_EXIT__;
- INM_LOGI("inm_supplicant_bss_add failed");
- return;
- }
-
- __INM_FUNC_EXIT__;
- return;
-}
-
-static void __handle_bss_removed(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
-{
- __INM_FUNC_ENTER__;
- inm_supplicant_iface_s *iface = NULL;
- const gchar *path = NULL;
- gint ret = 0;
- __INM_FUNC_ENTER__;
-
- g_variant_get(parameters, "(o)", &path);
- if (!path) {
- __INM_FUNC_EXIT__;
- return;
- }
-
- iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
- if (!iface) {
- __INM_FUNC_EXIT__;
- INM_LOGI("iface not found");
- return;
- }
-
- ret = inm_supplicant_bss_remove(path, iface->bss_tbl);
- if (ret < 0) {
- __INM_FUNC_EXIT__;
- INM_LOGI("inm_supplicant_bss_remove failed");
- return;
- }
-
- __INM_FUNC_EXIT__;
- return;
-}
-
-static void __handle_blob_added(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
-{
- __INM_FUNC_ENTER__;
-
- __INM_FUNC_EXIT__;
- return;
-}
-
-static void __handle_blob_removed(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
-{
- __INM_FUNC_ENTER__;
-
- __INM_FUNC_EXIT__;
- return;
-}
-
-static void __handle_network_added(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
-{
- __INM_FUNC_ENTER__;
-
- __INM_FUNC_ENTER__;
- inm_supplicant_iface_s *iface = NULL;
- GVariantIter *iter = NULL;
- const gchar *path = NULL;
- gint ret = 0;
- __INM_FUNC_ENTER__;
-
- g_variant_get(parameters, "(oa{sv})", &path, &iter);
- if (!path || !iter) {
- __INM_FUNC_EXIT__;
- return;
- }
-
- iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
- if (!iface) {
- __INM_FUNC_EXIT__;
- INM_LOGI("iface not found");
- return;
- }
-
- ret = inm_supplicant_network_add(path, iter, &(iface->current_network));
- if (ret < 0) {
- __INM_FUNC_EXIT__;
- INM_LOGI("inm_supplicant_network_add failed");
- return;
- }
-
- __INM_FUNC_EXIT__;
- return;
-}
-
-static void __handle_network_removed(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
-{
- __INM_FUNC_ENTER__;
- inm_supplicant_iface_s *iface = NULL;
- const gchar *path = NULL;
- gint ret = 0;
- __INM_FUNC_ENTER__;
-
- g_variant_get(parameters, "(o)", &path);
- if (!path) {
- __INM_FUNC_EXIT__;
- return;
- }
-
- iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
- if (!iface) {
- __INM_FUNC_EXIT__;
- INM_LOGI("iface not found");
- return;
- }
-
- ret = inm_supplicant_network_remove(path, iface->current_network);
- if (ret < 0) {
- __INM_FUNC_EXIT__;
- INM_LOGI("inm_supplicant_network_remove failed");
- return;
- }
- iface->current_network = NULL;
-
- __INM_FUNC_EXIT__;
- return;
-}
-
-static void __handle_network_selected(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
-{
- __INM_FUNC_ENTER__;
- inm_supplicant_iface_s *iface = NULL;
- const gchar *path = NULL;
- gint ret = 0;
-
- g_variant_get(parameters, "(o)", &path);
- if (!path) {
- __INM_FUNC_EXIT__;
- return;
- }
-
- iface = g_hash_table_lookup(g_supplicant_iface_tbl, object_path);
- if (!iface) {
- __INM_FUNC_EXIT__;
- INM_LOGI("iface not found");
- return;
- }
-
- ret = inm_supplicant_network_select(path, iface->current_network);
- if (ret < 0) {
- __INM_FUNC_EXIT__;
- INM_LOGI("inm_supplicant_network_select failed");
- return;
- }
-
- __INM_FUNC_EXIT__;
- return;
-}
-
-static void __handle_sta_authorized(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
+DECLARE_DBUS_SIGNAL_HANDLER(handle_scan_done)
{
__INM_FUNC_ENTER__;
- __INM_FUNC_EXIT__;
- return;
-}
-
-static void __handle_sta_deauthorized(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
-{
- __INM_FUNC_ENTER__;
+ PRINT_STR("<WPA event:Scan done>");
__INM_FUNC_EXIT__;
return;
}
-static void __handle_certification(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
+DECLARE_DBUS_SIGNAL_HANDLER(handle_sta_authorized)
{
__INM_FUNC_ENTER__;
- __INM_FUNC_EXIT__;
- return;
-}
-
-static void __handle_eap(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
-{
- __INM_FUNC_ENTER__;
+ PRINT_STR("<WPA event:Sta authorized>");
__INM_FUNC_EXIT__;
return;
}
-static void __handle_network_request(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
+DECLARE_DBUS_SIGNAL_HANDLER(handle_sta_deauthorized)
{
__INM_FUNC_ENTER__;
- __INM_FUNC_EXIT__;
- return;
-}
-
-static void __handle_probe_request(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
-{
- __INM_FUNC_ENTER__;
+ PRINT_STR("<WPA event:Sta deauthorized>");
__INM_FUNC_EXIT__;
return;
}
-static void __handle_wps_event(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
+DECLARE_DBUS_SIGNAL_HANDLER(handle_wps_event)
{
__INM_FUNC_ENTER__;
return;
}
-static void __handle_wps_credentials(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
+DECLARE_DBUS_SIGNAL_HANDLER(handle_wps_credentials)
{
__INM_FUNC_ENTER__;
return;
}
-static void __iface_properties_changed(const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal,
- GVariant *parameters,
- gpointer user_data)
+DECLARE_DBUS_SIGNAL_HANDLER(iface_properties_changed)
{
inm_supplicant_iface_s *iface = NULL;
inm_supplicant_iface_property_e changed = INM_SUPPLICANT_IFACE_PROPERTY_NONE;
scanning = iface->scanning;
if (parameters)
- __get_iface_properties_without_bss(parameters, iface);
+ __get_iface_properties(parameters, iface);
if (iface->state == IFACE_STATE_COMPLETED)
inm_supplicant_iface_signal_poll(object_path);
gchar *key = NULL;
gint ret = 0;
__INM_FUNC_ENTER__;
- iface->bss_tbl = g_hash_table_new_full(g_str_hash,
- g_str_equal,
- g_free,
- inm_supplicant_bss_destroy
- );
-
- if (!iface->bss_tbl) {
- INM_LOGI("Error! Failed to allocate bss tbl");
- __INM_FUNC_EXIT__;
- return -1;
- }
key = g_strdup(path);
if (g_hash_table_replace(g_supplicant_iface_tbl, key, iface))
return -1;
}
- ret = inm_supplicant_p2p_init(path, &(iface->p2p));
- if (ret != INM_GDBUS_ERROR_NONE)
- INM_LOGI("inm_supplicant_p2p_init failed");
-
return 0;
}
return INM_SUPPLICANT_ERROR_OPERATION_FAILED;
}
- ret = inm_supplicant_p2p_deinit(iface->p2p);
- if (ret != INM_SUPPLICANT_ERROR_NONE)
- INM_LOGI("inm_supplicant_p2p_deinit failed");
- iface->p2p = NULL;
-
g_hash_table_remove(g_supplicant_iface_tbl, path);
__INM_FUNC_EXIT__;
int ret = INM_GDBUS_ERROR_NONE;
__INM_FUNC_ENTER__;
+ method_param_s get_iface_property_method_param = {
+ .bus_name = SUPPLICANT_SERVICE,
+ .object_path = NULL,
+ .interface_name = DBUS_PROPERTIES_INTERFACE,
+ .method_name = DBUS_PROPERTIES_METHOD_GETALL,
+ .parameters = NULL,
+ };
+
get_iface_property_method_param.object_path = path;
get_iface_property_method_param.parameters = g_variant_new("(s)",
SUPPLICANT_IFACE_INTERFACE);
return INM_SUPPLICANT_ERROR_INVALID_PARAM;
}
+
+ method_param_s signal_poll_method_param = {
+ .bus_name = SUPPLICANT_SERVICE,
+ .object_path = NULL,
+ .interface_name = SUPPLICANT_IFACE_INTERFACE,
+ .method_name = "SignalPoll",
+ .parameters = NULL,
+ };
+
signal_poll_method_param.object_path = path;
ret = inm_gdbus_method_call(&signal_poll_method_param,
SIGNAL_IFACE_ADDED,
SIGNAL_IFACE_REMOVED,
SIGNAL_PROP_CHANGED,
- SIGNAL_NAME_OWNER_CHANGED,
SIGNAL_MAX,
} supplicant_signal_e;
-typedef struct {
- gboolean is_initialized;
- guint eap_methods;
- guint capabilities;
- guchar ies[WFDIE_SUBELEM_LEN_DEV_INFO + 3];
-
-} supplicant_mon_s;
-
-supplicant_mon_s supplicant_mon;
-
-void __iface_added(
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data);
-
-void __iface_removed(
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data);
-
-void __supplicant_properties_changed(
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data);
-
-static void __name_owner_changed_cb(
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data);
-
-static signal_param_s signal_param[] = {
+static gboolean is_initialized = FALSE;
+
+static DECLARE_DBUS_SIGNAL_HANDLER(iface_added);
+static DECLARE_DBUS_SIGNAL_HANDLER(iface_removed);
+static DECLARE_DBUS_SIGNAL_HANDLER(supplicant_properties_changed);
+
+signal_param_s signal_param[] = {
{
.sender = SUPPLICANT_SERVICE,
.interface_name = SUPPLICANT_INTERFACE,
.callback = __supplicant_properties_changed,
.subscriber_id = 0,
},
- {
- .sender = DBUS_SERVICE_DBUS,
- .interface_name = DBUS_INTERFACE_DBUS,
- .member = DBUS_SIGNAL_NAME_CHANGED,
- .object_path = NULL,
- .arg0 = SUPPLICANT_SERVICE,
- .callback = __name_owner_changed_cb,
- .subscriber_id = 0,
- },
-};
-
-static method_param_s get_supplicant_property_method_param = {
- .bus_name = SUPPLICANT_SERVICE,
- .object_path = SUPPLICANT_PATH,
- .interface_name = DBUS_PROPERTIES_INTERFACE,
- .method_name = DBUS_PROPERTIES_METHOD_GETALL,
- .parameters = NULL,
};
-static gboolean __unpack_ays(unsigned char *dst, GVariant *src, int size)
-{
- GVariantIter *iter = NULL;
- int length = 0;
- int res = FALSE;
-
- if (!dst || !src || size == 0) {
- INM_LOGW("Invalid parameter");
- return FALSE;
- }
-
- g_variant_get(src, "ay", &iter);
- if (iter == NULL) {
- INM_LOGW("failed to get iterator");
- return FALSE;
- }
-
- while (g_variant_iter_loop(iter, "y", &dst[length])) {
- length++;
- if (length >= size)
- break;
- }
- g_variant_iter_free(iter);
-
- if (length < size) {
- INM_LOGW("array is shorter than size");
- res = FALSE;
- }
-
- return res;
-}
-
-static void __name_owner_changed_cb(
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data)
-{
- gchar *name = NULL;
- gchar *old = NULL;
- gchar *new = NULL;
- __INM_FUNC_ENTER__;
-
- if (parameters == NULL)
- return;
-
- g_variant_get(parameters, "(&s&s&s)", &name, &old, &new);
-
- if (g_strcmp0(name, SUPPLICANT_SERVICE) == 0 && *new == '\0')
- INM_LOGI("Supplicant destroyed: name %s, old %s, new %s", name, old, new);
-
- __INM_FUNC_EXIT__;
- return;
-}
-
static inline void __get_supplicant_interface(GVariant *value)
{
GVariantIter *iter = NULL;
__INM_FUNC_EXIT__;
}
-static inline void __get_supplicant_eap_method(GVariant *value, supplicant_mon_s *supp)
-{
- GVariantIter *iter = NULL;
- const gchar *method = NULL;
- __INM_FUNC_ENTER__;
-
- g_variant_get(value, "as", &iter);
-
- supp->eap_methods = EAP_METHOD_UNKNOWN;
- while (g_variant_iter_loop(iter, "s", &method)) {
- /* Check Type of DNS Address */
- if (g_strcmp0(method, "MD5") == 0)
- supp->eap_methods |= CAPABILITY_AP;
- else if (g_strcmp0(method, "TLS") == 0)
- supp->eap_methods |= EAP_METHOD_TLS;
- else if (g_strcmp0(method, "MSCHAPV2") == 0)
- supp->eap_methods |= EAP_METHOD_MSCHPV2;
- else if (g_strcmp0(method, "PEAP") == 0)
- supp->eap_methods |= EAP_METHOD_PEAP;
- else if (g_strcmp0(method, "TTLS") == 0)
- supp->eap_methods |= EAP_METHOD_TTLS;
- else if (g_strcmp0(method, "GTC") == 0)
- supp->eap_methods |= EAP_METHOD_GTC;
- else if (g_strcmp0(method, "OTP") == 0)
- supp->eap_methods |= EAP_METHOD_OTP;
- else if (g_strcmp0(method, "LEAP") == 0)
- supp->eap_methods |= EAP_METHOD_LEAP;
- else if (g_strcmp0(method, "WSC") == 0)
- supp->eap_methods |= EAP_METHOD_WSC;
- }
- g_variant_iter_free(iter);
- __INM_FUNC_EXIT__;
-}
-
-static inline void __get_supplicant_capability(GVariant *value, supplicant_mon_s *supp)
-{
- GVariantIter *iter = NULL;
- const gchar *cap = NULL;
- __INM_FUNC_ENTER__;
-
- g_variant_get(value, "as", &iter);
-
- supp->capabilities = CAPABILITY_UNKNOWN;
- while (g_variant_iter_loop(iter, "s", &cap)) {
- /* Check Type of DNS Address */
- if (g_strcmp0(cap, "ap") == 0)
- supp->capabilities |= CAPABILITY_AP;
- else if (g_strcmp0(cap, "ibss-rsn") == 0)
- supp->capabilities |= CAPABILITY_IBSS_RSN ;
- else if (g_strcmp0(cap, "p2p") == 0)
- supp->capabilities |= CAPABILITY_P2P ;
- else if (g_strcmp0(cap, "interworking") == 0)
- supp->capabilities |= CAPABILITY_INTERWORKING ;
- }
- g_variant_iter_free(iter);
- __INM_FUNC_EXIT__;
-}
-
-void __get_supplicant_property(gchar *key, GVariant *value, supplicant_mon_s *supp)
+void __get_supplicant_property(gchar *key, GVariant *value)
{
__INM_FUNC_ENTER__;
if (g_strcmp0(key, "Interfaces") == 0)
__get_supplicant_interface(value);
- else if (g_strcmp0(key, "EapMethods") == 0)
- __get_supplicant_eap_method(value, supp);
- else if (g_strcmp0(key, "Capabilities") == 0)
- __get_supplicant_capability(value, supp);
- else if (g_strcmp0(key, "WFDIEs") == 0)
- if (__unpack_ays(supp->ies, value, WFDIE_SUBELEM_LEN_DEV_INFO + 3)) {
- INM_LOGI("WFDIEs valid");
- }
__INM_FUNC_EXIT__;
}
GVariantIter *iter = NULL;
gchar *key = NULL;
GVariant *var = NULL;
- supplicant_mon_s *supp = NULL;
__INM_FUNC_ENTER__;
- if (!value || !user_data) {
+ if (!value) {
__INM_FUNC_EXIT__;
return;
}
return;
}
- supp = (supplicant_mon_s *)user_data;
while (g_variant_iter_loop(iter, "{sv}", &key, &var))
- __get_supplicant_property(key, var, supp);
+ __get_supplicant_property(key, var);
g_variant_iter_free(iter);
return;
}
-void __iface_added(
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data)
+
+static DECLARE_DBUS_SIGNAL_HANDLER(iface_added)
{
__INM_FUNC_ENTER__;
const gchar *path = NULL;
GVariantIter *iter = NULL;
- g_variant_get(parameters, "(oa{sv})", &path, &iter);
+ g_variant_get(parameters, "(&oa{sv})", &path, &iter);
if (path && iter)
inm_supplicant_iface_add(path, iter);
return;
}
-void __iface_removed(
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data)
+static DECLARE_DBUS_SIGNAL_HANDLER(iface_removed)
{
__INM_FUNC_ENTER__;
const gchar *path = NULL;
- g_variant_get(parameters, "(o)", &path);
+ g_variant_get(parameters, "(&o)", &path);
if (path)
inm_supplicant_iface_remove(path);
else
return;
}
-void __supplicant_properties_changed(
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
- GVariant *parameters,
- gpointer user_data)
+static DECLARE_DBUS_SIGNAL_HANDLER(supplicant_properties_changed)
{
__INM_FUNC_ENTER__;
if (parameters)
- __get_supplicant_properties(parameters, &supplicant_mon);
+ __get_supplicant_properties(parameters, NULL);
__INM_FUNC_EXIT__;
}
-
int inm_supplicant_get_properties()
{
int ret = INM_SUPPLICANT_ERROR_NONE;
__INM_FUNC_ENTER__;
- get_supplicant_property_method_param.parameters = g_variant_new("(s)",
- SUPPLICANT_INTERFACE);
+ method_param_s get_supplicant_property_method_param = {
+ .bus_name = SUPPLICANT_SERVICE,
+ .object_path = SUPPLICANT_PATH,
+ .interface_name = DBUS_PROPERTIES_INTERFACE,
+ .method_name = DBUS_PROPERTIES_METHOD_GETALL,
+ .parameters = g_variant_new("(s)",
+ SUPPLICANT_INTERFACE),
+ };
ret = inm_gdbus_method_call(&get_supplicant_property_method_param,
__get_supplicant_properties,
- (gpointer)&supplicant_mon);
+ NULL);
if (ret != INM_GDBUS_ERROR_NONE) {
__INM_FUNC_EXIT__;
return INM_SUPPLICANT_ERROR_METHOD_CALL_FAILED;
return INM_SUPPLICANT_ERROR_NONE;
}
-int inm_supplicant_get_eap_methods(unsigned int *eap_methods)
-{
- int ret = INM_SUPPLICANT_ERROR_NONE;
- __INM_FUNC_ENTER__;
-
- if (!supplicant_mon.is_initialized) {
- __INM_FUNC_EXIT__;
- return INM_SUPPLICANT_ERROR_NOT_INITIALIZED;
- }
-
- if (!eap_methods) {
- __INM_FUNC_EXIT__;
- return INM_SUPPLICANT_ERROR_INVALID_PARAM;
- }
-
- *eap_methods = supplicant_mon.eap_methods;
-
-
- __INM_FUNC_EXIT__;
- return ret;
-}
-
-int inm_supplicant_get_capabilities(unsigned int *capabilities)
-{
- int ret = INM_SUPPLICANT_ERROR_NONE;
- __INM_FUNC_ENTER__;
-
- if (!supplicant_mon.is_initialized) {
- __INM_FUNC_EXIT__;
- return INM_SUPPLICANT_ERROR_NOT_INITIALIZED;
- }
-
- if (!capabilities) {
- __INM_FUNC_EXIT__;
- return INM_SUPPLICANT_ERROR_INVALID_PARAM;
- }
-
- *capabilities = supplicant_mon.capabilities;
-
- __INM_FUNC_EXIT__;
- return ret;
-}
-
-int inm_supplicant_get_wfd_ies(unsigned char *ies, unsigned int *length)
+static inline int __subscribe_supplicant_signal()
{
int ret = INM_SUPPLICANT_ERROR_NONE;
- __INM_FUNC_ENTER__;
- if (!supplicant_mon.is_initialized) {
- __INM_FUNC_EXIT__;
- return INM_SUPPLICANT_ERROR_NOT_INITIALIZED;
- }
+ ret = inm_gdbus_subscribe_signal(&(signal_param[SIGNAL_IFACE_ADDED]));
+ if (ret != INM_GDBUS_ERROR_NONE)
+ return INM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
- if (!ies || !length) {
- __INM_FUNC_EXIT__;
- return INM_SUPPLICANT_ERROR_INVALID_PARAM;
- }
+ ret = inm_gdbus_subscribe_signal(&(signal_param[SIGNAL_IFACE_REMOVED]));
+ if (ret != INM_GDBUS_ERROR_NONE)
+ return INM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
- memcpy(ies, supplicant_mon.ies, WFDIE_SUBELEM_LEN_DEV_INFO + 3);
- *length = WFDIE_SUBELEM_LEN_DEV_INFO + 3;
+ ret = inm_gdbus_subscribe_signal(&(signal_param[SIGNAL_PROP_CHANGED]));
+ if (ret != INM_GDBUS_ERROR_NONE)
+ return INM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
- __INM_FUNC_EXIT__;
return ret;
}
int ret = INM_SUPPLICANT_ERROR_NONE;
__INM_FUNC_ENTER__;
- memset(&supplicant_mon, 0x00, sizeof(supplicant_mon));
- supplicant_mon.is_initialized = TRUE;
+ if (is_initialized)
+ return ret;
ret = inm_gdbus_subscribe_signal(&(signal_param[SIGNAL_IFACE_ADDED]));
if (ret != INM_GDBUS_ERROR_NONE) {
return INM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
}
- ret = inm_gdbus_subscribe_signal(&(signal_param[SIGNAL_NAME_OWNER_CHANGED]));
- if (ret != INM_GDBUS_ERROR_NONE) {
- __INM_FUNC_EXIT__;
- return INM_SUPPLICANT_ERROR_SIGNAL_SUBSCRIBE_FAILED;
- }
-
ret = inm_supplicant_iface_init();
if (ret != INM_SUPPLICANT_ERROR_NONE) {
__INM_FUNC_EXIT__;
int ret = INM_SUPPLICANT_ERROR_NONE;
__INM_FUNC_ENTER__;
- if (!supplicant_mon.is_initialized) {
+ if (!is_initialized) {
__INM_FUNC_EXIT__;
return INM_SUPPLICANT_ERROR_NOT_INITIALIZED;
}
inm_gdbus_unsubscribe_signal(&(signal_param[SIGNAL_IFACE_ADDED]));
inm_gdbus_unsubscribe_signal(&(signal_param[SIGNAL_IFACE_REMOVED]));
inm_gdbus_unsubscribe_signal(&(signal_param[SIGNAL_PROP_CHANGED]));
- inm_gdbus_unsubscribe_signal(&(signal_param[SIGNAL_NAME_OWNER_CHANGED]));
- memset(&supplicant_mon, 0x00, sizeof(supplicant_mon));
- supplicant_mon.is_initialized = FALSE;
+ is_initialized = FALSE;
__INM_FUNC_EXIT__;
return ret;