Add security type and passphrase
authorJiwan Kim <ji-wan.kim@samsung.com>
Fri, 9 Jun 2017 08:02:14 +0000 (17:02 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 17 Jul 2017 02:09:10 +0000 (11:09 +0900)
- Add mesh_security_type_e
- Add mesh_network_get(set)_security()
- Add mesh_network_set_passphrase

include/mesh.h
include/mesh_private.h
src/mesh.c
src/mesh_dbus.c
test/main.c
test/mesh_network.c

index 72e11f5..ae8bf09 100644 (file)
@@ -88,6 +88,22 @@ typedef enum {
 #define MAX_BSSID_LEN 18
 
 /**
+ * @brief The maximum length of passphrase
+ *
+ * @since_tizen 4.0
+ */
+#define MAX_PASSPHRASE_LEN (64+1)
+
+/**
+ * @brief Enumeration for the security type of the Mesh network.
+ * @since_tizen 4.0
+ */
+typedef enum {
+       MESH_SECURITY_NONE = 0, /**< Open network */
+       MESH_SECURITY_SAE, /**< Simultaneous Authentication of Equals */
+} mesh_security_type_e;
+
+/**
  * @brief Enumeration for the connection state of the Mesh network.
  * @since_tizen 4.0
  */
@@ -141,6 +157,7 @@ typedef struct {
        char mesh_id[MAX_MESHID_LEN]; /**< The Mesh ID of the network that generated the event */
        char bssid[MAX_BSSID_LEN]; /**< The BSSID of the network that generated the event */
        int channel; /**< The channel of the network that generated the event */
+       mesh_security_type_e security; /**< The security type of network */
        mesh_connection_state_e state; /**< The state of mesh network connection. */
 } mesh_connection_state_event_s;
 
@@ -250,6 +267,8 @@ int mesh_network_clone(mesh_network_h* dst, mesh_network_h src);
  * @param[in] channel The operating channel number
  * @param[in] rssi The Received Signal Strength Indicator
  * @param[in] data_rate The maximum data rate
+ * @param[in] security The security type for network
+ * @param[in] passphrase The passphrase for network connection
  *
  * @return 0 on success, otherwise a negative error value.
  * @retval #MESH_ERROR_NONE Successful
@@ -262,7 +281,8 @@ int mesh_network_clone(mesh_network_h* dst, mesh_network_h src);
  *
  */
 int mesh_network_new_with(mesh_network_h* network, const char *meshid,
-       const char *bssid, int channel, int rssi, int data_rate);
+       const char *bssid, int channel, int rssi, int data_rate,
+       mesh_security_type_e security, const char *passphrase);
 
 /**
  * @brief Destroys network handle for network information.
@@ -317,7 +337,7 @@ int mesh_network_get_meshid(mesh_network_h network, char **meshid);
  * @retval #MESH_ERROR_NONE Successful
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  *
- * @see mesh_network_set_meshid()
+ * @see mesh_network_get_meshid()
  *
  */
 int mesh_network_set_meshid(mesh_network_h network, const char *meshid);
@@ -354,7 +374,7 @@ int mesh_network_get_bssid(mesh_network_h network, char **bssid);
  * @retval #MESH_ERROR_NONE Successful
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  *
- * @see mesh_network_set_meshid()
+ * @see mesh_network_get_bssid()
  *
  */
 int mesh_network_set_bssid(mesh_network_h network, const char *bssid);
@@ -408,7 +428,7 @@ int mesh_network_set_channel(mesh_network_h network, int channel);
  * @retval #MESH_ERROR_NONE Successful
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  *
- * @see mesh_network_get_rssi()
+ * @see mesh_network_set_rssi()
  *
  */
 int mesh_network_get_rssi(mesh_network_h network, int *rssi);
@@ -444,7 +464,7 @@ int mesh_network_set_rssi(mesh_network_h network, int rssi);
  * @retval #MESH_ERROR_NONE Successful
  * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
  *
- * @see mesh_network_get_data_rate()
+ * @see mesh_network_set_data_rate()
  *
  */
 int mesh_network_get_data_rate(mesh_network_h network, int *data_rate);
@@ -468,6 +488,60 @@ int mesh_network_get_data_rate(mesh_network_h network, int *data_rate);
 int mesh_network_set_data_rate(mesh_network_h network, int data_rate);
 
 /**
+ * @brief Gets the security type.
+ * @details This function is to get the security type.
+ *
+ * @since_tizen 4.0
+ *
+ * @param[in] network The mesh network information handle.
+ * @param[out] security The security type for network.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MESH_ERROR_NONE Successful
+ * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see mesh_network_set_security()
+ *
+ */
+int mesh_network_get_security(mesh_network_h network, mesh_security_type_e *security);
+
+/**
+ * @brief Sets the security type.
+ * @details This function is to set the security type.
+ *
+ * @since_tizen 4.0
+ *
+ * @param[in] network The mesh network information handle.
+ * @param[in] security The security type for network.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MESH_ERROR_NONE Successful
+ * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see mesh_network_get_security()
+ *
+ */
+int mesh_network_set_security(mesh_network_h network, mesh_security_type_e security);
+
+/**
+ * @brief Sets the passphrase for network connection.
+ * @details This function is to set the passphrase.
+ *
+ * @since_tizen 4.0
+ *
+ * @param[in] network The mesh network information handle.
+ * @param[in] passphrase The passphrase for network connection.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MESH_ERROR_NONE Successful
+ * @retval #MESH_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see mesh_network_get_security()
+ * @see mesh_network_set_security()
+ */
+int mesh_network_set_passphrase(mesh_network_h network, const char* passphrase);
+
+/**
  * @brief Gets the connection state.
  * @details This function is to get the connection state
  *
index d3525f7..63a22ab 100644 (file)
@@ -78,7 +78,8 @@ struct mesh_network_s {
        int channel; /**< Channel */
        int rssi; /**< RSSI */
        int data_rate; /**< Data rate */
-       int security; /**< Security type */
+       mesh_security_type_e security; /**< Security type */
+       char passphrase[MAX_PASSPHRASE_LEN]; /**< Passphrase */
        mesh_connection_state_e state; /**< Connection state */
 };
 
index 2670ef2..3b72797 100644 (file)
@@ -13,6 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+#include <stdio.h>
 #include <stdlib.h>
 
 #include "mesh.h"
@@ -62,12 +64,14 @@ EXPORT_API int mesh_network_clone(mesh_network_h* dst, mesh_network_h src)
                LOGE("Out of memory"); //LCOV_EXCL_LINE
                return MESH_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
        }
-       memcpy(net->meshid, _src->meshid, MAX_MESHID_LEN);
-       memcpy(net->bssid, _src->bssid, MAX_BSSID_LEN);
+       snprintf(net->meshid, MAX_MESHID_LEN, "%s", _src->meshid);
+       snprintf(net->bssid, MAX_BSSID_LEN, "%s", _src->bssid);
        net->channel = _src->channel;
        net->rssi = _src->rssi;
        net->data_rate = _src->data_rate;
        net->security = _src->security;
+       if (_src->passphrase)
+               snprintf(net->passphrase, MAX_PASSPHRASE_LEN, "%s", _src->passphrase);
 
        *dst = (mesh_network_h)net;
 
@@ -75,7 +79,8 @@ EXPORT_API int mesh_network_clone(mesh_network_h* dst, mesh_network_h src)
 }
 
 EXPORT_API int mesh_network_new_with(mesh_network_h* network, const char *meshid,
-       const char *bssid, int channel, int rssi, int data_rate)
+       const char *bssid, int channel, int rssi, int data_rate,
+       mesh_security_type_e security, const char *passphrase)
 {
        struct mesh_network_s *net;
 
@@ -87,11 +92,17 @@ EXPORT_API int mesh_network_new_with(mesh_network_h* network, const char *meshid
        }
 
        net = calloc(1, sizeof(struct mesh_network_s));
-       if (meshid) memcpy(net->meshid, meshid, MAX_MESHID_LEN);
-       if (bssid) memcpy(net->bssid, bssid, MAX_BSSID_LEN);
+       if (meshid)
+               snprintf(net->meshid, MAX_MESHID_LEN, "%s", meshid);
+       if (bssid)
+               snprintf(net->bssid, MAX_BSSID_LEN, "%s", bssid);
        net->channel = channel;
        net->rssi = rssi;
        net->data_rate = data_rate;
+       net->security = security;
+       if (passphrase)
+               snprintf(net->passphrase, MAX_PASSPHRASE_LEN, "%s", passphrase);
+
        *network = (mesh_network_h)net;
 
        return MESH_ERROR_NONE;
@@ -102,11 +113,12 @@ EXPORT_API void mesh_network_destroy(mesh_network_h network)
        struct mesh_network_s *net = network;
        CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
 
-       if (net == NULL) {
+       if (NULL == net) {
                LOGE("Invalid parameter"); //LCOV_EXCL_LINE
                return; //LCOV_EXCL_LINE
        }
-       if (net) free(net);
+
+       free(net);
 }
 
 EXPORT_API int mesh_network_get_meshid(mesh_network_h network, char **meshid)
@@ -136,7 +148,7 @@ EXPORT_API int mesh_network_set_meshid(mesh_network_h network, const char *meshi
                return MESH_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
-       memcpy(net->meshid, meshid, MAX_MESHID_LEN);
+       snprintf(net->meshid, MAX_MESHID_LEN, "%s", meshid);
 
        return MESH_ERROR_NONE;
 }
@@ -168,7 +180,7 @@ EXPORT_API int mesh_network_set_bssid(mesh_network_h network, const char *bssid)
                return MESH_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
-       memcpy(net->bssid, bssid, MAX_BSSID_LEN);
+       snprintf(net->bssid, MAX_BSSID_LEN, "%s", bssid);
 
        return MESH_ERROR_NONE;
 }
@@ -216,7 +228,7 @@ EXPORT_API int mesh_network_get_rssi(mesh_network_h network, int *rssi)
                return MESH_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
-       *rssi = net->channel;
+       *rssi = net->rssi;
 
        return MESH_ERROR_NONE;
 }
@@ -248,7 +260,7 @@ EXPORT_API int mesh_network_get_data_rate(mesh_network_h network, int *data_rate
                return MESH_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
-       *data_rate = net->channel;
+       *data_rate = net->data_rate;
 
        return MESH_ERROR_NONE;
 }
@@ -269,6 +281,57 @@ EXPORT_API int mesh_network_set_data_rate(mesh_network_h network, int data_rate)
        return MESH_ERROR_NONE;
 }
 
+EXPORT_API int mesh_network_get_security(mesh_network_h network, mesh_security_type_e *security)
+{
+       struct mesh_network_s *net = (struct mesh_network_s *)network;
+
+       CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+       if (network == NULL || security == NULL ) {
+               LOGE("Invalid parameter"); //LCOV_EXCL_LINE
+               return MESH_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       }
+
+       *security = net->security;
+
+       return MESH_ERROR_NONE;
+}
+
+EXPORT_API int mesh_network_set_security(mesh_network_h network, mesh_security_type_e security)
+{
+       struct mesh_network_s *net = (struct mesh_network_s *)network;
+
+       CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+       if (network == NULL) {
+               LOGE("Invalid parameter"); //LCOV_EXCL_LINE
+               return MESH_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       }
+
+       net->security = security;
+
+       return MESH_ERROR_NONE;
+}
+
+EXPORT_API int mesh_network_set_passphrase(mesh_network_h network, const char* passphrase)
+{
+       struct mesh_network_s *net = (struct mesh_network_s *)network;
+
+       CHECK_FEATURE_SUPPORTED(MESH_FEATURE);
+
+       if (network == NULL) {
+               LOGE("Invalid parameter"); //LCOV_EXCL_LINE
+               return MESH_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
+       }
+
+       if (passphrase)
+               snprintf(net->passphrase, MAX_PASSPHRASE_LEN, "%s", passphrase);
+       else
+               memset(net->passphrase, 0x0, MAX_PASSPHRASE_LEN);
+
+       return MESH_ERROR_NONE;
+}
+
 EXPORT_API int mesh_network_get_connection_state(mesh_network_h network,
                mesh_connection_state_e *state)
 {
index 31585bf..838ecd4 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <stdio.h>
 #include <stdlib.h>
 
 #include "mesh.h"
@@ -191,25 +192,31 @@ int _mesh_get_scan_result(mesh_h handle)
                        struct mesh_network_s *network_info =
                                g_malloc0(sizeof(struct mesh_network_s));
                        while (g_variant_iter_loop(iter_row, "{sv}", &key, &val)) {
-                               if (strcasecmp(key, "mesh_id") == 0)  {
+                               if (strcasecmp(key, "mesh_id") == 0) {
                                        const char *buf = g_variant_get_string(val, &len);
                                        memcpy(network_info->meshid, buf, len);
                                        LOGD("  MeshID [%s]", network_info->meshid);
                                }
-                               else if (strcasecmp(key, "bssid") == 0)  {
+                               else if (strcasecmp(key, "bssid") == 0) {
                                        const char *buf = g_variant_get_string(val, &len);
                                        memcpy(network_info->bssid, buf, len);
                                        LOGD("  BSSID [%s]", network_info->bssid);
                                }
-                               else if (strcasecmp(key, "rssi") == 0)  {
+                               else if (strcasecmp(key, "rssi") == 0) {
                                        network_info->rssi = g_variant_get_int32(val);
                                        LOGD("  RSSI [%d]", network_info->rssi);
                                }
-                               else if (strcasecmp(key, "channel") == 0)  {
+                               else if (strcasecmp(key, "channel") == 0) {
                                        network_info->channel = g_variant_get_uint32(val);
                                        LOGD("  Channel [%d]", network_info->channel);
                                }
-                               else if (strcasecmp(key, "state") == 0)  {
+                               else if (strcasecmp(key, "security") == 0) {
+                                       guint sec = g_variant_get_uint32(val);
+                                       network_info->security = ((1 == sec) ? MESH_SECURITY_SAE : MESH_SECURITY_NONE);
+                                       LOGD("  Security [%s]",
+                                               (MESH_SECURITY_SAE == network_info->security) ? "SAE" : "NONE");
+                               }
+                               else if (strcasecmp(key, "state") == 0) {
                                        network_info->state = g_variant_get_uint32(val);
                                        LOGD("  State [%d]", network_info->state);
                                }
@@ -311,9 +318,10 @@ static void _mesh_signal_handler(GDBusConnection *connection,
                char *bssid = NULL;
                int channel = 0;
                int state = 0;
+               int security = 0;
                mesh_event_data_s ev;
 
-               g_variant_get(parameters, "(ssii)", &mesh_id, &bssid, &channel, &state);
+               g_variant_get(parameters, "(ssiii)", &mesh_id, &bssid, &channel, &security, &state);
 
                ev.data.connection_state = calloc(1, sizeof(mesh_connection_state_event_s));
                RETM_IF(NULL == ev.data.connection_state, "Failed to memory allocation !");
@@ -321,6 +329,7 @@ static void _mesh_signal_handler(GDBusConnection *connection,
                g_snprintf(ev.data.connection_state->mesh_id, MAX_MESHID_LEN, "%s", mesh_id);
                g_snprintf(ev.data.connection_state->bssid, MAX_BSSID_LEN, "%s", bssid);
                ev.data.connection_state->channel = channel;
+               ev.data.connection_state->security = (mesh_security_type_e)security;
                ev.data.connection_state->state = (mesh_connection_state_e)state;
 
                h->event_handler(MESH_CONNECTION_STATE_EVENT, &ev);
@@ -333,7 +342,7 @@ static void _mesh_signal_handler(GDBusConnection *connection,
                g_variant_get(parameters, "(s)", &bssid);
                memcpy(ev.data.sta_info->bssid, bssid, MAX_BSSID_LEN);
                h->event_handler(MESH_STATION_JOIN_EVENT, &ev);
-               g_free(ev.data.sta_info);
+               free(ev.data.sta_info);
        } else if (0 == g_strcmp0(signal_name, "sta_left")) {
                char *bssid = NULL;
                mesh_event_data_s ev;
@@ -342,7 +351,7 @@ static void _mesh_signal_handler(GDBusConnection *connection,
                g_variant_get(parameters, "(s)", &bssid);
                memcpy(ev.data.sta_info->bssid, bssid, MAX_BSSID_LEN);
                h->event_handler(MESH_STATION_LEFT_EVENT, &ev);
-               g_free(ev.data.sta_info);
+               free(ev.data.sta_info);
        }
 }
 
@@ -842,10 +851,12 @@ int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h* _network)
                char *meshid = NULL;
                char *bssid = NULL;
                int channel = -1;
+               int security = -1;
                int state = 0;
                int svc_result = 0;
 
-               g_variant_get(variant, "(ssiii)", &meshid, &bssid, &channel, &state, &svc_result);
+               g_variant_get(variant, "(ssiiii)", &meshid, &bssid, &channel,
+                       &security, &state, &svc_result);
                LOGD("get_joined_mesh_network status 0x%x", svc_result);
                result = __convert_service_error_type(svc_result);
 
@@ -855,7 +866,7 @@ int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h* _network)
                g_joined_network.channel = 0;
                g_joined_network.rssi = -1;
                g_joined_network.data_rate = 0;
-               g_joined_network.security = 0;
+               g_joined_network.security = MESH_SECURITY_NONE;
                g_joined_network.state = MESH_CONNECTION_STATE_DISCONNECTED;
 
                if (SERVICE_ERROR_NO_DATA == svc_result) {
@@ -868,14 +879,15 @@ int _mesh_get_joined_mesh_network(mesh_h handle, mesh_network_h* _network)
 
                if (meshid) {
                        LOGE("  Mesh ID : %s", meshid);
-                       g_snprintf(g_joined_network.meshid, MAX_MESHID_LEN, "%s", meshid);
+                       snprintf(g_joined_network.meshid, MAX_MESHID_LEN, "%s", meshid);
                }
                if (bssid) {
                        LOGE("  BSSID   : %s", bssid);
-                       g_snprintf(g_joined_network.bssid, MAX_BSSID_LEN, "%s", bssid);
+                       snprintf(g_joined_network.bssid, MAX_BSSID_LEN, "%s", bssid);
                }
                g_joined_network.channel = channel;
                g_joined_network.rssi = -1;
+               g_joined_network.security = security;
                g_joined_network.state = state;
 
                *_network = &g_joined_network;
@@ -1073,7 +1085,7 @@ int _mesh_connect_network(mesh_h handle, mesh_network_h _network)
        RETV_IF(NULL == _gproxy_mesh_service, MESH_ERROR_IO_ERROR);
 
        variant = g_dbus_proxy_call_sync(_gproxy_mesh_service, "connect_mesh_network",
-                               g_variant_new("(sii)", n->meshid, n->channel, n->security),
+                               g_variant_new("(siis)", n->meshid, n->channel, n->security, n->passphrase),
                                G_DBUS_CALL_FLAGS_NONE,
                                -1,
                                NULL, &error);
index 7f9de82..1a286d5 100644 (file)
@@ -100,10 +100,11 @@ void event_cb(mesh_event_e event_type, mesh_event_data_s* event)
                case MESH_CONNECTION_STATE_EVENT:{
                        msgp("  Connection state changed [%s]",
                                _mesh_connection_event_to_string(event->data.connection_state->state));
-                       msgp("  From Mesh ID[%-10s] BSSID[%s] Channel[%d]",
+                       msgp("  From Mesh ID[%-10s] BSSID[%s] Channel[%d] Security[%4s]",
                                event->data.connection_state->mesh_id,
                                event->data.connection_state->bssid,
-                               event->data.connection_state->channel);
+                               event->data.connection_state->channel,
+                               (MESH_SECURITY_SAE == event->data.connection_state->security) ? "SAE" : "NONE");
                } break;
                case MESH_STATION_JOIN_EVENT: {
                        msgp("  New Station Joined = %s", event->data.sta_info->bssid);
index 29bc543..7d0b403 100644 (file)
@@ -42,6 +42,8 @@ static char security[MENU_DATA_SIZE + 1] = "2";
 
 static char meshid[MENU_DATA_SIZE + 1] = "meshnet";
 static char mesh_channel[MENU_DATA_SIZE + 1] = "161";
+static char mesh_security[MENU_DATA_SIZE + 1] = "0";
+static char mesh_passphrase[MENU_DATA_SIZE + 1] = "";
 
 static char network_idx[MENU_DATA_SIZE + 1] = "1";
 
@@ -55,6 +57,7 @@ static void found_mesh_network_cb(mesh_network_h network, void* user_data)
        mesh_network_h net = NULL;
        char *meshid = NULL;
        char *bssid = NULL;
+       mesh_security_type_e security;
        int channel;
 
        ret = mesh_network_clone(&net, network);
@@ -68,7 +71,10 @@ static void found_mesh_network_cb(mesh_network_h network, void* user_data)
        mesh_network_get_meshid(net, &meshid);
        mesh_network_get_bssid(net, &bssid);
        mesh_network_get_channel(net, &channel);
-       msgb("  [%02d] Mesh ID[%-10s] BSSID[%s] Channel[%d]", g_scan_net_idx, meshid, bssid, channel);
+       mesh_network_get_security(net, &security);
+       msgb("  [%02d] Mesh ID[%-10s] BSSID[%s] Channel[%d] Security[%4s]",
+               g_scan_net_idx, meshid, bssid, channel,
+               (MESH_SECURITY_SAE == security) ? "SAE" : "NONE");
 
        g_scan_net_idx++;
 
@@ -97,11 +103,13 @@ static void found_mpath_cb(mesh_mpath_info_h mpath, void* user_data)
        msg("Station Information Received: %p", mpath);
 }
 
+#if 0
 static int run_show_found_network(MManager *mm, struct menu_data *menu)
 {
        int i = 1; /* Displays from 1 */
        char *_meshid = NULL;
        int _channel = 1;
+       mesh_security_type_e _security = MESH_SECURITY_NONE;
 
        GList *iter = NULL;
 
@@ -116,7 +124,9 @@ static int run_show_found_network(MManager *mm, struct menu_data *menu)
                mesh_network_h _net = iter->data;
                mesh_network_get_meshid(_net, &_meshid);
                mesh_network_get_channel(_net, &_channel);
-               msgb("  [%02d] Mesh ID[%-10s] Channel[%d]", i++, _meshid, _channel);
+               mesh_network_get_security(_net, &_security);
+               msgb("  [%02d] Mesh ID[%-10s] Channel[%d] Security[%4s]", i++,
+                       _meshid, _channel, (MESH_SECURITY_SAE == _security) ? "SAE" : "NONE");
 
                if (_meshid) free(_meshid);
 
@@ -125,6 +135,7 @@ static int run_show_found_network(MManager *mm, struct menu_data *menu)
 
        return RET_SUCCESS;
 }
+#endif
 
 static int run_mesh_scan(MManager *mm, struct menu_data *menu)
 {
@@ -239,6 +250,7 @@ static int run_get_joined_mesh_network(MManager *mm, struct menu_data *menu)
        char *_bssid = NULL;
        int _channel = -1;
        mesh_connection_state_e _state = MESH_CONNECTION_STATE_DISCONNECTED;
+       mesh_security_type_e _security = MESH_SECURITY_NONE;
        mesh_network_h network = NULL;
 
        msg("Get Joined Mesh Network Information");
@@ -252,13 +264,16 @@ static int run_get_joined_mesh_network(MManager *mm, struct menu_data *menu)
 
        if (NULL != network) {
                mesh_network_get_meshid(network, &_meshid);
-               msgb("  Mesh ID = %s", _meshid);
+               msgb("  Mesh ID  = %s", _meshid);
                mesh_network_get_bssid(network, &_bssid);
-               msgb("  BSSID   = %s", _bssid);
+               msgb("  BSSID    = %s", _bssid);
                mesh_network_get_channel(network, &_channel);
-               msgb("  Channel = %d", _channel);
+               msgb("  Channel  = %d", _channel);
+               mesh_network_get_security(network, &_security);
+               msgb("  Security = %s",
+                       (MESH_SECURITY_SAE == _security) ? "SAE" : "NONE");
                mesh_network_get_connection_state(network, &_state);
-               msgb("  State   = %s", _mesh_connection_event_to_string(_state));
+               msgb("  State    = %s", _mesh_connection_event_to_string(_state));
 
                if (_meshid) free(_meshid);
                if (_bssid) free(_bssid);
@@ -397,6 +412,7 @@ static int run_create_network(MManager *mm, struct menu_data *menu)
 {
        int ret;
        int _mesh_channel = 1;
+       mesh_security_type_e security = MESH_SECURITY_NONE;
        mesh_network_h net = NULL;
 
        msg("Create a new Mesh Network");
@@ -404,7 +420,12 @@ static int run_create_network(MManager *mm, struct menu_data *menu)
        if (strlen(mesh_channel))
                _mesh_channel = (unsigned short)strtol(mesh_channel, NULL, 10);
 
-       mesh_network_new_with(&net, meshid, NULL, _mesh_channel, 0, 0);
+       if (strlen(mesh_security)) {
+               ret = (unsigned short)strtol(mesh_security, NULL, 10);
+               security = ((1 == ret) ? MESH_SECURITY_SAE : MESH_SECURITY_NONE);
+       }
+
+       mesh_network_new_with(&net, meshid, NULL, _mesh_channel, 0, 0, security, NULL);
        ret = mesh_create_mesh_network(mesh, net);
        mesh_network_destroy(net);
        if (MESH_ERROR_NONE != ret) {
@@ -423,6 +444,7 @@ static int run_connect_network(MManager *mm, struct menu_data *menu)
        int ret;
        int idx = 1;
        mesh_network_h net = NULL;
+       mesh_security_type_e security = MESH_SECURITY_NONE;
        msg("Connect to Mesh Network");
 
        if (strlen(network_idx)) {
@@ -441,6 +463,19 @@ static int run_connect_network(MManager *mm, struct menu_data *menu)
                }
        }
 
+       /* Set passphrase */
+       mesh_network_get_security(net, &security);
+       if (MESH_SECURITY_NONE != security) {
+               if (strlen(mesh_passphrase)) {
+                       ret = mesh_network_set_passphrase(net, mesh_passphrase);
+                       if (MESH_ERROR_NONE != ret)
+                               msgr("Failed to set passphrase !");
+               } else {
+                       msgr("If security enabled, passphrase should be set !");
+                       return RET_FAILURE;
+               }
+       }
+
        ret = mesh_connect_mesh_network(mesh, net);
        if (MESH_ERROR_NONE != ret) {
                msgr("Failed to mesh_connect_mesh_network: [%s(0x%X)]",
@@ -585,26 +620,28 @@ static struct menu_data menu_softap_option[] = {
 static struct menu_data menu_create_network[] = {
        { "1", "Mesh ID", NULL, NULL, meshid },
        { "2", "Channel", NULL, NULL, mesh_channel },
-       { "3", "Run", NULL, run_create_network, NULL },
+       { "3", "Security (0=None,1=SAE)", NULL, NULL, mesh_security },
+       { "4", "Run", NULL, run_create_network, NULL },
        { NULL, NULL, },
 };
 
 static struct menu_data menu_connect_network[] = {
-       { "0", "Show found networks", NULL, run_show_found_network, NULL },
+       { "0", "Show found networks", NULL, run_get_found_mesh_network, NULL },
        { "1", "Index", NULL, NULL, network_idx },
-       { "2", "Run", NULL, run_connect_network, NULL },
+       { "2", "Passphrase", NULL, NULL, mesh_passphrase },
+       { "3", "Run", NULL, run_connect_network, NULL },
        { NULL, NULL, },
 };
 
 static struct menu_data menu_disconnect_network[] = {
-       { "0", "Show found networks", NULL, run_show_found_network, NULL },
+       { "0", "Show found networks", NULL, run_get_found_mesh_network, NULL },
        { "1", "Index", NULL, NULL, network_idx },
        { "2", "Run", NULL, run_disconnect_network, NULL },
        { NULL, NULL, },
 };
 
 static struct menu_data menu_forget_network[] = {
-       { "0", "Show found networks", NULL, run_show_found_network, NULL },
+       { "0", "Show found networks", NULL, run_get_found_mesh_network, NULL },
        { "1", "Index", NULL, NULL, network_idx },
        { "2", "Run", NULL, run_forget_network, NULL },
        { NULL, NULL, },