int mesh_ipc_get_connected_peers(mesh_service *service);
int mesh_ipc_get_joined_mesh_network(mesh_service *service);
-int mesh_ipc_create_network(mesh_service *service, gchar *mesh_id, gint channel,
- gint security);
+int mesh_ipc_create_network(mesh_service *service, gchar *mesh_id,
+ gint channel, meshd_security_type_e sec);
+int mesh_ipc_set_passphrase(mesh_service *service, mesh_scan_result_s *info,
+ gchar *passphrase);
int mesh_ipc_connect_network(mesh_service *service, mesh_scan_result_s *info);
int mesh_ipc_disconnect_network(mesh_service *service, mesh_scan_result_s *info);
int mesh_ipc_remove_network(mesh_service *service, mesh_scan_result_s *info);
int mesh_request_ipc_get_joined_network(mesh_service *service);
int mesh_request_ipc_create_mesh_network(mesh_service *service, gchar *mesh_id,
- gint channel, gint security);
+ gint channel, meshd_security_type_e sec);
int mesh_request_ipc_connect_mesh_network(mesh_service *service, gchar *mesh_id,
- gint channel, gint security);
+ gint channel, meshd_security_type_e sec, gchar *passphrase);
int mesh_request_ipc_disconnect_mesh_network(mesh_service *service,
- gchar *mesh_id, gint channel, gint security);
+ gchar *mesh_id, gint channel, meshd_security_type_e sec);
int mesh_request_ipc_remove_mesh_network(mesh_service *service,
- gchar *mesh_id, gint channel, gint security);
+ gchar *mesh_id, gint channel, meshd_security_type_e sec);
int mesh_request_enable_mesh(const char* base_interface,
const char* mesh_interface, GList *saved_network,
/* Notifications */
void mesh_notify_scan_done();
-//void mesh_notify_joined_network();
-//void mesh_notify_left_network();
-//void mesh_notify_mesh_connected(int result);
void mesh_notify_connection_state(const char* mesh_id, const char* bssid,
- int channel, meshd_connection_state_e state);
+ int channel, meshd_security_type_e sec, meshd_connection_state_e state);
void mesh_notify_station_joined(const char* bssid);
void mesh_notify_station_left(const char* bssid);
MESHD_CONNECTION_STATE_CONNECTED /**< Connected state */
} meshd_connection_state_e;
+/**< Internal enum for security type. It should be matched with API side */
+typedef enum {
+ MESHD_SECURITY_NONE = 0, /**< No security */
+ MESHD_SECURITY_SAE, /**< SAE */
+} meshd_security_type_e;
+
/**< mesh interface information structure */
typedef struct {
gchar *bridge_interface; /**< Bridge name between mesh and others */
char* mesh_id; /**< The mesh id */
char* bssid; /**< BSSID */
int channel; /**< Channel */
- int security; /**< Security type */
+ meshd_security_type_e security; /**< Security type */
meshd_connection_state_e state; /**< Connection state */
} mesh_network_info_s;
gint rssi; /**< RSSI */
gint channel; /**< Channel */
gint data_rate; /**< Data rate */
+ meshd_security_type_e security; /**< Security type */
meshd_connection_state_e state; /**< Connection state */
} mesh_scan_result_s;
<arg type="s" name="mesh_id" direction="out"/>\r
<arg type="s" name="bssid" direction="out"/>\r
<arg type="i" name="channel" direction="out"/>\r
+ <arg type="i" name="security" direction="out"/>\r
<arg type="i" name="state" direction="out"/>\r
<arg type="i" name="result" direction="out"/>\r
</method>\r
<arg type="s" name="mesh_id" direction="in"/>\r
<arg type="i" name="channel" direction="in"/>\r
<arg type="i" name="security" direction="in"/>\r
+ <arg type="s" name="passphrase" direction="in"/>\r
<arg type="i" name="result" direction="out"/>\r
</method>\r
<method name="disconnect_mesh_network">\r
<arg type="s" name="mesh_id" direction="out"/>\r
<arg type="s" name="bssid" direction="out"/>\r
<arg type="i" name="channel" direction="out"/>\r
+ <arg type="i" name="security" direction="out"/>\r
<arg type="i" name="state" direction="out"/>\r
</signal>\r
<signal name="sta_joined">\r
}
mesh_notify_connection_state(network_info.mesh_id, network_info.bssid,
- network_info.channel, state);
+ network_info.channel, network_info.security, state);
g_free(network_info.mesh_id);
g_free(network_info.bssid);
buf = g_variant_get_string(val, &len);
joined_info->mesh_id = g_strdup(buf);
}
- else if (strcasecmp(key, "Address") == 0) {
+ else if (strcasecmp(key, "BSSID") == 0) {
buf = g_variant_get_string(val, &len);
joined_info->bssid = g_strdup(buf);
}
joined_info->state = MESHD_CONNECTION_STATE_CONNECTED;
}
}
+ else if (strcasecmp(key, "Security") == 0) {
+ buf = g_variant_get_string(val, &len);
+ if (g_strcmp0("sae", buf) == 0)
+ joined_info->security = MESHD_SECURITY_SAE;
+ else
+ joined_info->security = MESHD_SECURITY_NONE;
+ }
else if (strcasecmp(key, "Frequency") == 0) {
joined_info->channel = __frequency_to_channel(g_variant_get_uint16(val));
}
continue;
}
- MESH_LOGD(" Mesh ID : %s", joined_info->mesh_id);
- MESH_LOGD(" BSSID : %s", joined_info->bssid);
- MESH_LOGD(" Channel : %d", joined_info->channel);
+ MESH_LOGD(" Mesh ID : %s", joined_info->mesh_id);
+ MESH_LOGD(" BSSID : %s", joined_info->bssid);
+ MESH_LOGD(" Channel : %d", joined_info->channel);
+ MESH_LOGD(" Security : %s",
+ (MESHD_SECURITY_SAE == joined_info->security) ? "SAE" : "NONE");
service->joined_network = joined_info;
g_variant_iter_free(property);
scan_info->mesh_id = g_strdup(buf);
MESH_LOGD(" Mesh ID : %s", scan_info->mesh_id);
}
- else if (strcasecmp(key, "Address") == 0) {
+ else if (strcasecmp(key, "BSSID") == 0) {
const char *buf = g_variant_get_string(val, &len);
scan_info->bssid = g_strdup(buf);
MESH_LOGD(" BSSID : %s", scan_info->bssid);
else if (strcasecmp(key, "Security") == 0) {
const char *buf = g_variant_get_string(val, &len);
MESH_LOGD(" Security : %s", buf);
+ if (g_strcmp0("sae", buf) == 0)
+ scan_info->security = MESHD_SECURITY_SAE;
+ else
+ scan_info->security = MESHD_SECURITY_NONE;
}
else if (strcasecmp(key, "Frequency") == 0) {
scan_info->channel = __frequency_to_channel(g_variant_get_uint16(val));
result->mesh_id = g_strdup(buf);
MESH_LOGD(" Mesh ID : %s", result->mesh_id);
}
- else if (strcasecmp(key, "Address") == 0) {
+ else if (strcasecmp(key, "BSSID") == 0) {
const char *buf = g_variant_get_string(val, &len);
result->bssid = g_strdup(buf);
MESH_LOGD(" BSSID : %s", result->bssid);
else if (strcasecmp(key, "Security") == 0) {
const char *buf = g_variant_get_string(val, &len);
MESH_LOGD(" Security : %s", buf);
+ if (g_strcmp0("sae", buf) == 0)
+ result->security = MESHD_SECURITY_SAE;
+ else
+ result->security = MESHD_SECURITY_NONE;
}
else if (strcasecmp(key, "Frequency") == 0) {
result->channel = __frequency_to_channel(g_variant_get_uint16(val));
return MESHD_ERROR_NONE;
}
-int mesh_ipc_create_network(mesh_service *service, gchar *mesh_id, gint channel,
- gint security)
+int mesh_ipc_create_network(mesh_service *service, gchar *mesh_id,
+ gint channel, meshd_security_type_e sec)
{
GVariant *variant = NULL;
GError *error = NULL;
GVariant *var_dict = NULL;
GVariantBuilder builder;
- const gchar* secu = (security == 0) ? "none" : "SAE";
+ const gchar* security = (MESHD_SECURITY_SAE == sec) ? "sae" : "none";
enum nl80211_band band = (channel <= 14) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
gushort freq = __channel_to_frequency(channel, band);
g_variant_builder_open(&builder, G_VARIANT_TYPE("{sv}"));
g_variant_builder_add(&builder, "s", "Security");
- g_variant_builder_add(&builder, "v", g_variant_new_string(secu));
+ g_variant_builder_add(&builder, "v", g_variant_new_string(security));
g_variant_builder_close(&builder); /* {sv} */
g_variant_builder_close(&builder); /* a{sv} */
return MESHD_ERROR_NONE;
}
+
+int mesh_ipc_set_passphrase(mesh_service *service, mesh_scan_result_s *info,
+ gchar *passphrase)
+{
+ GVariant *variant = NULL;
+ GError *error = NULL;
+
+ meshd_check_null_ret_error("service", service, MESHD_ERROR_INVALID_PARAMETER);
+ meshd_check_null_ret_error("passphrase", passphrase, MESHD_ERROR_INVALID_PARAMETER);
+
+ variant = g_dbus_connection_call_sync(service->connection,
+ CONNMAN_SERVER_NAME,
+ info->object_path,
+ CONNMAN_INTERFACE_MESH,
+ "SetProperty",
+ g_variant_new("(sv)", "Passphrase", g_variant_new_string(passphrase)),
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, NULL, &error);
+ if (variant) {
+ MESH_LOGD("Successfully requested. [SetProperty]");
+ } else if (error) {
+ LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return MESHD_ERROR_IO_ERROR;
+ }
+
+ return MESHD_ERROR_NONE;
+}
+
#if 0
static void on_response_connect_network(GObject *source_object,
GAsyncResult *res, gpointer user_data)
mesh_network_info_s *info = NULL;
GList *iter = NULL;
gboolean found = FALSE;
+ meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
meshd_check_null_ret_error("saved_network", saved_network,
MESHD_ERROR_INVALID_PARAMETER);
info = (mesh_network_info_s*)iter->data;
if (g_strcmp0(mesh_id, info->mesh_id) == 0) {
- if (info->channel == mesh_channel && info->security == security)
+ if (info->channel == mesh_channel && info->security == sec)
{
found = TRUE;
break;
mesh_network_info_s *info = NULL;
mesh_network_info_s *moved = NULL;
gboolean found = FALSE;
+ meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
meshd_check_null_ret_error("saved_network", saved_network,
MESHD_ERROR_INVALID_PARAMETER);
info = (mesh_network_info_s*)iter->data;
if (g_strcmp0(mesh_id, info->mesh_id) == 0) {
- if (info->channel == mesh_channel && info->security == security)
+ if (info->channel == mesh_channel && info->security == sec)
{
moved = g_try_new0(mesh_network_info_s, 1);
if (NULL == moved) {
GList *iter = NULL;
mesh_network_info_s *info = NULL;
gboolean found = FALSE;
+ meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
meshd_check_null_ret_error("saved_network", saved_network,
MESHD_ERROR_INVALID_PARAMETER);
info = (mesh_network_info_s*)iter->data;
if (g_strcmp0(mesh_id, info->mesh_id) == 0) {
- if (info->channel == mesh_channel && info->security == security)
+ if (info->channel == mesh_channel && info->security == sec)
{
found = TRUE;
break;
}
static int _select_matched_network(GList *scanned_network,
- const char *mesh_id, int mesh_channel, int security,
+ const char *mesh_id, int mesh_channel, meshd_security_type_e sec,
mesh_scan_result_s **info)
{
int ret = MESHD_ERROR_NONE;
mesh_scan_result_s *item = NULL;
gboolean found = FALSE;
- NOTUSED(security);
-
meshd_check_null_ret_error("scanned_network", scanned_network,
MESHD_ERROR_INVALID_PARAMETER);
item = (mesh_scan_result_s*)iter->data;
if (g_strcmp0(mesh_id, item->mesh_id) == 0) {
- if (item->channel == mesh_channel)
+ if (item->channel == mesh_channel && item->security == sec)
{
*info = item;
found = TRUE;
}
int mesh_request_ipc_create_mesh_network(mesh_service *service, gchar *mesh_id,
- gint channel, gint security)
+ gint channel, meshd_security_type_e sec)
{
int ret;
MESH_LOGD("[IPC] Create a new mesh network");
- ret = mesh_ipc_create_network(service, mesh_id, channel, security);
+ ret = mesh_ipc_create_network(service, mesh_id, channel, sec);
if(MESHD_ERROR_NONE != ret) {
MESH_LOGE("Failed to create mesh network");
return ret;
}
int mesh_request_ipc_connect_mesh_network(mesh_service *service, gchar *mesh_id,
- gint channel, gint security)
+ gint channel, meshd_security_type_e sec, gchar *passphrase)
{
int ret;
mesh_scan_result_s *info = NULL;
/* Get mesh_id and channel from saved network */
ret = _select_matched_network(service->scanned_mesh_network,
- mesh_id, channel, security, &info);
+ mesh_id, channel, sec, &info);
if(MESHD_ERROR_NONE != ret) {
MESH_LOGE("Failed to mesh_network_get_first_mesh_network");
return ret;
}
+ /* Set passphrase */
+ if (MESHD_SECURITY_NONE != sec) {
+ if (NULL != passphrase) {
+ ret = mesh_ipc_set_passphrase(service, info, passphrase);
+ if(MESHD_ERROR_NONE != ret) {
+ MESH_LOGE("Failed to set passphrase for mesh network");
+ return ret;
+ }
+ } else {
+ MESH_LOGE("Passphrase is required !");
+ return MESHD_ERROR_INVALID_PARAMETER;
+ }
+ }
+
ret = mesh_ipc_connect_network(service, info);
if(MESHD_ERROR_NONE != ret) {
MESH_LOGE("Failed to connect mesh network");
}
int mesh_request_ipc_disconnect_mesh_network(mesh_service *service,
- gchar *mesh_id, gint channel, gint security)
+ gchar *mesh_id, gint channel, meshd_security_type_e sec)
{
int ret;
mesh_scan_result_s *info = NULL;
/* Get mesh_id and channel from saved network */
ret = _select_matched_network(service->scanned_mesh_network,
- mesh_id, channel, security, &info);
+ mesh_id, channel, sec, &info);
if(MESHD_ERROR_NONE != ret) {
MESH_LOGE("Failed to _select_matched_network");
return ret;
}
int mesh_request_ipc_remove_mesh_network(mesh_service *service,
- gchar *mesh_id, gint channel, gint security)
+ gchar *mesh_id, gint channel, meshd_security_type_e sec)
{
int ret;
mesh_scan_result_s *info = NULL;
/* Get mesh_id and channel from saved network */
ret = _select_matched_network(service->scanned_mesh_network,
- mesh_id, channel, security, &info);
+ mesh_id, channel, sec, &info);
if(MESHD_ERROR_NONE != ret) {
MESH_LOGE("Failed to _select_matched_network");
return ret;
}
void mesh_notify_connection_state(const char* mesh_id, const char* bssid,
- int channel, meshd_connection_state_e state)
+ int channel, meshd_security_type_e sec, meshd_connection_state_e state)
{
NetMesh *object = meshd_dbus_get_object();
- net_mesh_emit_connection_state(object, mesh_id, bssid, channel, (int)state);
+ net_mesh_emit_connection_state(object, mesh_id, bssid, channel,
+ (int)sec, (int)state);
}
void mesh_notify_station_joined(const char* bssid)
g_variant_new_int32(scan_item->rssi));
g_variant_builder_add(&builder, "{sv}", "channel",
g_variant_new_uint32(scan_item->channel));
+ g_variant_builder_add(&builder, "{sv}", "security",
+ g_variant_new_uint32((int)scan_item->security));
g_variant_builder_add(&builder, "{sv}", "state",
g_variant_new_uint32(scan_item->state));
g_variant_builder_close(&builder);
if (joined) {
net_mesh_complete_get_joined_mesh_network(object, invocation,
joined->mesh_id, joined->bssid,
- joined->channel, joined->state, ret);
+ joined->channel, (int)joined->security,
+ joined->state, ret);
} else {
net_mesh_complete_get_joined_mesh_network(object, invocation,
- "", "", 0, 0, MESHD_ERROR_NO_DATA);
+ "", "", 0, 0, 0, MESHD_ERROR_NO_DATA);
}
} else {
net_mesh_complete_get_joined_mesh_network(object, invocation,
- "", "", 0, 0, ret);
+ "", "", 0, 0, 0, ret);
}
return TRUE;
{
int ret = MESHD_ERROR_NONE;
mesh_service *service = (mesh_service *)user_data;
+ meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
//ret = mesh_request_add_mesh_network(&service->saved_mesh_network,
// mesh_id, channel, security);
- ret = mesh_request_ipc_create_mesh_network(service, mesh_id, channel, security);
+ ret = mesh_request_ipc_create_mesh_network(service, mesh_id, channel, sec);
net_mesh_complete_create_mesh_network(object, invocation, ret);
#endif
static gboolean _meshd_dbus_handle_connect_mesh_network(NetMesh *object,
GDBusMethodInvocation *invocation,
- gchar *mesh_id, gint channel, gint security,
+ gchar *mesh_id, gint channel, gint security, gchar *passphrase,
gpointer user_data)
{
int ret = MESHD_ERROR_NONE;
mesh_service *service = (mesh_service *)user_data;
-
+ meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
//ret = mesh_request_select_saved_mesh_network(&service->saved_mesh_network,
// mesh_id, channel, security);
/* ADDED */
- ret = mesh_request_ipc_connect_mesh_network(service, mesh_id, channel, security);
+ ret = mesh_request_ipc_connect_mesh_network(service, mesh_id, channel, sec, passphrase);
/* ADDED */
net_mesh_complete_connect_mesh_network(object, invocation, ret);
{
int ret = MESHD_ERROR_NONE;
mesh_service *service = (mesh_service *)user_data;
+ meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
- ret = mesh_request_ipc_disconnect_mesh_network(service, mesh_id, channel, security);
+ ret = mesh_request_ipc_disconnect_mesh_network(service, mesh_id, channel, sec);
net_mesh_complete_disconnect_mesh_network(object, invocation, ret);
{
int ret = MESHD_ERROR_NONE;
mesh_service *service = (mesh_service *)user_data;
+ meshd_security_type_e sec = (1 == security) ? MESHD_SECURITY_SAE : MESHD_SECURITY_NONE;
//ret = mesh_request_forget_saved_mesh_network(&service->saved_mesh_network,
// mesh_id, channel, security);
- ret = mesh_request_ipc_remove_mesh_network(service,
- mesh_id, channel, security);
+ ret = mesh_request_ipc_remove_mesh_network(service, mesh_id, channel, sec);
net_mesh_complete_forget_mesh_network(object, invocation, ret);