+ if (wps_mode & WIFI_DIRECT_WPS_TYPE_PBC)
+ result = callback(WIFI_DIRECT_WPS_TYPE_PBC, user_data);
+
+ if ((result == true) && (wps_mode & WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY))
+ result = callback(WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY, user_data);
+
+
+ if ((result == true) && (wps_mode & WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD))
+ result = callback(WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD, user_data);
+ }
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! Invalid resp cmd = %d\n",
+ rsp.cmd);
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+ }
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+
+}
+
+
+int wifi_direct_set_wps_type(wifi_direct_wps_type_e type)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if ((client_info->is_registered == false)
+ || (client_info->client_id == WFD_INVALID_ID))
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ if (type == WIFI_DIRECT_WPS_TYPE_PBC
+ || type == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY
+ || type == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Param wps_mode [%d]\n", type);
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Invalid Param [wps_mode]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ wifi_direct_client_request_s req;
+ wifi_direct_client_response_s rsp;
+
+ int status = WIFI_DIRECT_ERROR_NONE;
+
+ memset(&req, 0, sizeof(wifi_direct_client_request_s));
+ memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
+
+ req.cmd = WIFI_DIRECT_CMD_SET_CURRENT_WPS_MODE;
+ req.client_id = client_info->client_id;
+
+ status =__wfd_client_send_request(client_info->sync_sockfd, &req,
+ sizeof(wifi_direct_client_request_s));
+ if (status != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! writing to socket, Errno = %s\n",
+ strerror(errno));
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n",
+ __wfd_print_error(status));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "writing msg hdr is success!\n");
+
+ status =
+ __wfd_client_send_request(client_info->sync_sockfd, &type,
+ sizeof(wifi_direct_wps_type_e));
+ if (status != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! writing to socket, Errno = %s\n",
+ strerror(errno));
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n",
+ __wfd_print_error(status));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+
+ if ((status =
+ __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
+ sizeof(wifi_direct_client_response_s))) <= 0)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! reading socket, status = %d errno = %s\n",
+ status, strerror(errno));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+ else
+ {
+ if (rsp.cmd == WIFI_DIRECT_CMD_SET_CURRENT_WPS_MODE)
+ {
+ if (rsp.result != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! Result received = %d \n",
+ rsp.result);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! [%s]\n",
+ __wfd_print_error(rsp.result));
+ __WFD_CLIENT_FUNC_END__;
+ return rsp.result;
+ }
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! Invalid resp cmd = %d\n",
+ rsp.cmd);
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+ }
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+int wifi_direct_get_wps_type(wifi_direct_wps_type_e* type)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if ((client_info->is_registered == false)
+ || (client_info->client_id == WFD_INVALID_ID))
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ if (type == NULL)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [type]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ wifi_direct_client_request_s req;
+ wifi_direct_client_response_s rsp;
+ wfd_config_data_s ls_config;
+
+ int status = WIFI_DIRECT_ERROR_NONE;
+
+ memset(&req, 0, sizeof(wifi_direct_client_request_s));
+ memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
+
+ req.cmd = WIFI_DIRECT_CMD_GET_CONFIG;
+ req.client_id = client_info->client_id;
+
+ status =
+ __wfd_client_send_request(client_info->sync_sockfd, &req,
+ sizeof(wifi_direct_client_request_s));
+ if (status != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! writing to socket, Errno = %s\n",
+ strerror(errno));
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n",
+ __wfd_print_error(status));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+
+ if ((status =
+ __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
+ sizeof(wifi_direct_client_response_s))) <= 0)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! reading socket, status = %d errno = %s\n",
+ status, strerror(errno));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+ else
+ {
+ if (rsp.cmd == WIFI_DIRECT_CMD_GET_CONFIG)
+ {
+ if (rsp.result != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! Result received = %d \n", rsp.result);
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n",
+ __wfd_print_error(rsp.result));
+ __WFD_CLIENT_FUNC_END__;
+ return rsp.result;
+ }
+ else
+ {
+ int status = 0;
+
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Link status = %d \n",
+ (int) rsp.param1);
+
+ status =
+ __wfd_client_read_more_data(client_info->sync_sockfd,
+ &ls_config,
+ sizeof(wfd_config_data_s));
+ if (status != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "socket read error.\n");
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+
+ __wfd_client_print_config_data(&ls_config);
+
+ *type = ls_config.wps_config;
+
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "wifi_direct_get_wps_type() SUCCESS\n");
+ }
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! Invalid resp cmd = %d\n",
+ rsp.cmd);
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+ }
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+int wifi_direct_set_ssid(const char *ssid)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if ((client_info->is_registered == false)
+ || (client_info->client_id == WFD_INVALID_ID))
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ if (NULL == ssid)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [ssid]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "ssid = [%s]\n", ssid);
+
+ wifi_direct_client_request_s req;
+ wifi_direct_client_response_s rsp;
+
+ int status = WIFI_DIRECT_ERROR_NONE;
+
+ memset(&req, 0, sizeof(wifi_direct_client_request_s));
+ memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
+
+ req.cmd = WIFI_DIRECT_CMD_SET_SSID;
+ req.client_id = client_info->client_id;
+
+ status =
+ __wfd_client_send_request(client_info->sync_sockfd, &req,
+ sizeof(wifi_direct_client_request_s));
+ if (status != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! writing to socket, Errno = %s\n",
+ strerror(errno));
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n",
+ __wfd_print_error(status));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "writing msg hdr is success!\n");
+
+ status =
+ __wfd_client_send_request(client_info->sync_sockfd, ssid,
+ WIFI_DIRECT_MAX_SSID_LEN);
+ if (status != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! writing to socket, Errno = %s\n",
+ strerror(errno));
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n",
+ __wfd_print_error(status));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+
+ if ((status =
+ __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
+ sizeof(wifi_direct_client_response_s))) <= 0)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! reading socket, status = %d errno = %s\n",
+ status, strerror(errno));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+ else
+ {
+ if (rsp.cmd == WIFI_DIRECT_CMD_SET_SSID)
+ {
+ if (rsp.result != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! Result received = %d \n", rsp.result);
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n",
+ __wfd_print_error(rsp.result));
+ __WFD_CLIENT_FUNC_END__;
+ return rsp.result;
+ }
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! Invalid resp cmd = %d\n",
+ rsp.cmd);
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+ }
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+
+int wifi_direct_get_ssid(char **ssid)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == ssid)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [ssid]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ if ((client_info->is_registered == false)
+ || (client_info->client_id == WFD_INVALID_ID))
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ wifi_direct_client_request_s req;
+ wifi_direct_client_response_s rsp;
+ char la_ssid[WIFI_DIRECT_MAX_SSID_LEN + 1] = { 0, };
+
+ int status = WIFI_DIRECT_ERROR_NONE;
+
+ memset(&req, 0, sizeof(wifi_direct_client_request_s));
+ memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
+
+ req.cmd = WIFI_DIRECT_CMD_GET_SSID;
+ req.client_id = client_info->client_id;
+
+ status =
+ __wfd_client_send_request(client_info->sync_sockfd, &req,
+ sizeof(wifi_direct_client_request_s));
+ if (status != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! writing to socket, Errno = %s\n",
+ strerror(errno));
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n",
+ __wfd_print_error(status));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+
+ if ((status =
+ __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
+ sizeof(wifi_direct_client_response_s))) <= 0)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! reading socket, status = %d errno = %s\n",
+ status, strerror(errno));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+ else
+ {
+ if (rsp.cmd == WIFI_DIRECT_CMD_GET_SSID)
+ {
+ if (rsp.result != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! Result received = %d \n",
+ rsp.result);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! [%s]\n",
+ __wfd_print_error(rsp.result));
+ __WFD_CLIENT_FUNC_END__;
+ return rsp.result;
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW,
+ "wifi_direct_get_ssid() %s SUCCESS \n",
+ rsp.param2);
+ strncpy(la_ssid, rsp.param2, WIFI_DIRECT_MAX_SSID_LEN);
+
+ char *temp_ssid = NULL;
+ temp_ssid = strdup(la_ssid);
+ if (NULL == temp_ssid)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for SSID\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *ssid = temp_ssid;
+ }
+
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! Invalid resp cmd = %d\n",
+ rsp.cmd);
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+ }
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+int wifi_direct_get_network_interface_name(char** name)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == name)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [name]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ if ((client_info->is_registered == false)
+ || (client_info->client_id == WFD_INVALID_ID))
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ wifi_direct_state_e status = 0;
+ int result;
+ result = wifi_direct_get_state(&status);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "wifi_direct_get_state() state=[%d], result=[%d]\n", status, result);
+
+ if( status < WIFI_DIRECT_STATE_CONNECTED)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Device is not connected!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+
+ char* get_str = NULL;
+ get_str = vconf_get_str(VCONFKEY_IFNAME);
+
+ if (get_str == NULL)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "vconf (%s) value is NULL!!!\n", VCONFKEY_IFNAME);
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "VCONFKEY_IFNAME(%s) : %s\n", VCONFKEY_IFNAME, get_str);
+
+ char *temp_ifname = NULL;
+ temp_ifname = strdup(get_str);
+ if (NULL == temp_ifname)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for ifname.\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *name = temp_ifname;
+ }
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+
+int wifi_direct_get_ip_address(char **ip_address)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == ip_address)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [ip_address]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ if ((client_info->is_registered == false)
+ || (client_info->client_id == WFD_INVALID_ID))
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ wifi_direct_state_e state = 0;
+ int result;
+ result = wifi_direct_get_state(&state);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "wifi_direct_get_state() state=[%d], result=[%d]\n", state, result);
+
+ if( state < WIFI_DIRECT_STATE_CONNECTED)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Device is not connected!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+
+ char* get_str = NULL;
+ get_str = vconf_get_str(VCONFKEY_LOCAL_IP);
+
+ if (get_str == NULL)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "vconf (%s) value is NULL!!!\n", VCONFKEY_LOCAL_IP);
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "VCONFKEY_LOCAL_IP(%s) : %s\n", VCONFKEY_LOCAL_IP, get_str);
+
+ char *temp_ip = NULL;
+ temp_ip = strdup(get_str);
+ if (NULL == temp_ip)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for local ip address.\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *ip_address = temp_ip;
+ }
+
+
+#if 0
+ wifi_direct_client_request_s req;
+ wifi_direct_client_response_s rsp;
+ char la_ip[64] = { 0, };
+
+ int status = WIFI_DIRECT_ERROR_NONE;
+
+ memset(&req, 0, sizeof(wifi_direct_client_request_s));
+ memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
+
+ req.cmd = WIFI_DIRECT_CMD_GET_IP_ADDR;
+ req.client_id = client_info->client_id;
+
+ status =
+ __wfd_client_send_request(client_info->sync_sockfd, &req,
+ sizeof(wifi_direct_client_request_s));
+ if (status != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! writing to socket, Errno = %s\n",
+ strerror(errno));
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n",
+ __wfd_print_error(status));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+
+ if ((status =
+ __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
+ sizeof(wifi_direct_client_response_s))) <= 0)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! reading socket, status = %d errno = %s\n",
+ status, strerror(errno));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+ else
+ {
+ if (rsp.cmd == WIFI_DIRECT_CMD_GET_IP_ADDR)
+ {
+ if (rsp.result != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! Result received = %d \n",
+ rsp.result);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! [%s]\n",
+ __wfd_print_error(rsp.result));
+ __WFD_CLIENT_FUNC_END__;
+ return rsp.result;
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW,
+ "wifi_direct_get_ip_address() SUCCESS \n");
+ strncpy(la_ip, rsp.param2, strlen(rsp.param2));
+
+ char *temp_ip = NULL;
+ temp_ip = strdup(la_ip);
+ if (NULL == temp_ip)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for IP address\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *ip_address = temp_ip;
+ }
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! Invalid resp cmd = %d\n",
+ rsp.cmd);
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+ }
+#endif
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+int wifi_direct_get_subnet_mask(char** subnet_mask)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == subnet_mask)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [subnet_mask]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ if ((client_info->is_registered == false)
+ || (client_info->client_id == WFD_INVALID_ID))
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ wifi_direct_state_e status = 0;
+ int result;
+ result = wifi_direct_get_state(&status);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "wifi_direct_get_state() state=[%d], result=[%d]\n", status, result);
+
+ if( status < WIFI_DIRECT_STATE_CONNECTED)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Device is not connected!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+
+
+ char* get_str = NULL;
+ get_str = vconf_get_str(VCONFKEY_SUBNET_MASK);
+
+ if (get_str == NULL)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "vconf (%s) value is NULL!!!\n", VCONFKEY_SUBNET_MASK);
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "VCONFKEY_SUBNET_MASK(%s) : %s\n", VCONFKEY_SUBNET_MASK, get_str);
+
+ char *temp_subnetmask = NULL;
+ temp_subnetmask = strdup(get_str);
+ if (NULL == temp_subnetmask)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for subnet mask.\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *subnet_mask = temp_subnetmask;
+ }
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+int wifi_direct_get_gateway_address(char** gateway_address)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == gateway_address)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [gateway_address]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ if ((client_info->is_registered == false)
+ || (client_info->client_id == WFD_INVALID_ID))
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ wifi_direct_state_e status = 0;
+ int result;
+ result = wifi_direct_get_state(&status);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "wifi_direct_get_state() state=[%d], result=[%d]\n", status, result);
+
+ if( status < WIFI_DIRECT_STATE_CONNECTED)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Device is not connected!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+
+ char* get_str = NULL;
+ get_str = vconf_get_str(VCONFKEY_GATEWAY);
+
+ if (get_str == NULL)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "vconf (%s) value is NULL!!!\n", VCONFKEY_GATEWAY);
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "VCONFKEY_GATEWAY(%s) : %s\n", VCONFKEY_GATEWAY, get_str);
+
+ char *temp_gateway = NULL;
+ temp_gateway = strdup(get_str);
+ if (NULL == temp_gateway)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for gateway address.\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *gateway_address = temp_gateway;
+ }
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+int wifi_direct_get_mac_address(char **mac_address)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == mac_address)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [mac_address]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ if ((client_info->is_registered == false)
+ || (client_info->client_id == WFD_INVALID_ID))
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Client is NOT registered.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+#if 0
+ wifi_direct_client_request_s req;
+ wifi_direct_client_response_s rsp;
+ unsigned char la_mac_addr[6] = { 0, };
+
+ int status = WIFI_DIRECT_ERROR_NONE;
+
+ memset(&req, 0, sizeof(wifi_direct_client_request_s));
+ memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
+
+ req.cmd = WIFI_DIRECT_CMD_GET_DEVICE_MAC;
+ req.client_id = client_info->client_id;
+
+ status =
+ __wfd_client_send_request(client_info->sync_sockfd, &req,
+ sizeof(wifi_direct_client_request_s));
+ if (status != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! writing to socket, Errno = %s\n",
+ strerror(errno));
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! [%s]\n",
+ __wfd_print_error(status));
+ close(client_info->sync_sockfd);
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+
+ if ((status =
+ __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
+ sizeof(wifi_direct_client_response_s))) <= 0)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW,
+ "Error!!! reading socket, status = %d errno = %s\n",
+ status, strerror(errno));
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+ else
+ {
+ if (rsp.cmd == WIFI_DIRECT_CMD_GET_DEVICE_MAC)
+ {
+ if (rsp.result != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! Result received = %d \n",
+ rsp.result);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! [%s]\n",
+ __wfd_print_error(rsp.result));
+ __WFD_CLIENT_FUNC_END__;
+ return rsp.result;
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW,
+ "wifi_direct_get_mac_addr() SUCCESS \n");
+ strncpy((char *) la_mac_addr, (char *) rsp.param2,
+ strlen(rsp.param2));
+
+ char *temp_mac = NULL;
+ temp_mac = (char *) calloc(1, 18);
+ if (NULL == temp_mac)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for MAC address\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ sprintf(temp_mac, MACSTR, MAC2STR(la_mac_addr));
+
+ *mac_address = temp_mac;
+
+ }
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! Invalid resp cmd = %d\n",
+ rsp.cmd);
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+ }
+
+#else
+ int fd;
+ int n;
+ char mac_info[18];
+ unsigned char la_mac_addr[6];
+
+ memset(mac_info, 0, sizeof(mac_info));
+
+ if( (fd = open(WIFI_DIRECT_MAC_ADDRESS_INFO_FILE, O_RDONLY)) == -1)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "[.mac.info] file open failed.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+
+ n = read(fd, mac_info, 18);
+ if(n < 0)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "[.mac.info] file read failed.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "mac_address = [%s]\n", mac_info);
+
+ memset(la_mac_addr, 0, sizeof(la_mac_addr));
+ macaddr_atoe(mac_info, la_mac_addr);
+ la_mac_addr[0] = la_mac_addr[0] | 0x02;
+ la_mac_addr[1] = la_mac_addr[1];
+ la_mac_addr[2] = la_mac_addr[2];
+ la_mac_addr[3] = la_mac_addr[3];
+ la_mac_addr[4] = la_mac_addr[4];
+ la_mac_addr[5] = la_mac_addr[5];
+
+ char *temp_mac = NULL;
+ temp_mac = (char *) calloc(1, 18);
+ if (NULL == temp_mac)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to allocate memory for MAC address\n");
+ return WIFI_DIRECT_ERROR_OUT_OF_MEMORY;
+ }
+
+ //strncpy(temp_mac, mac_info, strlen(mac_info));
+ snprintf(temp_mac, 18, MACSTR, MAC2STR(la_mac_addr));
+
+ *mac_address = temp_mac;
+
+#endif
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+int wifi_direct_get_state(wifi_direct_state_e * state)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == state)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [state]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ if ((client_info->is_registered == false)
+ || (client_info->client_id == WFD_INVALID_ID))
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ wifi_direct_client_request_s req;
+ wifi_direct_client_response_s rsp;
+
+ int ret = WIFI_DIRECT_ERROR_NONE;
+
+ memset(&req, 0, sizeof(wifi_direct_client_request_s));
+ memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
+
+ req.cmd = WIFI_DIRECT_CMD_GET_LINK_STATUS;
+ req.client_id = client_info->client_id;
+
+ ret =
+ __wfd_client_send_request(client_info->sync_sockfd, &req,
+ sizeof(wifi_direct_client_request_s));
+ if (ret != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! writing to socket, Errno = %s\n",
+ strerror(errno));
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n",
+ __wfd_print_error(ret));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+
+ if ((ret =
+ __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
+ sizeof(wifi_direct_client_response_s))) <= 0)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! reading socket, status = %d errno = %s\n", ret,
+ strerror(errno));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+ else
+ {
+ if (rsp.cmd == WIFI_DIRECT_CMD_GET_LINK_STATUS)
+ {
+ if (rsp.result != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW,
+ "Error!!! Result received = %d %s\n", rsp.result,
+ __wfd_print_error(rsp.result));
+ __WFD_CLIENT_FUNC_END__;
+ return rsp.result;
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Link Status = %d \n",
+ (int) rsp.param1);
+ *state = (wifi_direct_state_e) rsp.param1;
+
+ /* for CAPI : there is no WIFI_DIRECT_STATE_GROUP_OWNER type in CAPI */
+ if(*state == WIFI_DIRECT_STATE_GROUP_OWNER)
+ *state = WIFI_DIRECT_STATE_CONNECTED;
+
+ }
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! Invalid resp cmd = %d\n",
+ rsp.cmd);
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+ }
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+int wifi_direct_is_discoverable(bool* discoverable)
+{
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (discoverable == NULL)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [discoverable]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ if ((client_info->is_registered == false)
+ || (client_info->client_id == WFD_INVALID_ID))
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ wifi_direct_client_request_s req;
+ wifi_direct_client_response_s rsp;
+
+ int status = WIFI_DIRECT_ERROR_NONE;
+
+ memset(&req, 0, sizeof(wifi_direct_client_request_s));
+ memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
+
+ req.cmd = WIFI_DIRECT_CMD_IS_DISCOVERABLE;
+ req.client_id = client_info->client_id;
+
+ status =
+ __wfd_client_send_request(client_info->sync_sockfd, &req,
+ sizeof(wifi_direct_client_request_s));
+ if (status != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! writing to socket, Errno = %s\n",
+ strerror(errno));
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n",
+ __wfd_print_error(status));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+
+ if ((status =
+ __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
+ sizeof(wifi_direct_client_response_s))) <= 0)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! reading socket, status = %d errno = %s\n",
+ status, strerror(errno));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+ else
+ {
+ if (rsp.cmd == WIFI_DIRECT_CMD_IS_DISCOVERABLE)
+ {
+ if (rsp.result != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! Result received = %d \n",
+ rsp.result);
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Error!!! [%s]\n",
+ __wfd_print_error(rsp.result));
+ __WFD_CLIENT_FUNC_END__;
+ return rsp.result;
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_LOW,
+ "wifi_direct_is_discoverable() %s SUCCESS \n",
+ rsp.param2);
+ *discoverable = (bool) rsp.param1;
+ }
+ }
+ else
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! Invalid resp cmd = %d\n",
+ rsp.cmd);
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+ }
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+
+}
+}
+
+
+int wifi_direct_get_primary_device_type(wifi_direct_primary_device_type_e* type)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if (NULL == type)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [type]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ if ((client_info->is_registered == false)
+ || (client_info->client_id == WFD_INVALID_ID))
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+
+ int result;
+ wifi_direct_config_data_s *config;
+ result = wifi_direct_get_config_data(&config);
+ if(result != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Failed to get wifi_direct_get_config_data() result=[%d]\n", result);
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ }
+
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Current primary_dev_type [%d]\n", config->primary_dev_type);
+
+ *type = config->primary_dev_type;
+
+ __WFD_CLIENT_FUNC_END__;
+
+ return WIFI_DIRECT_ERROR_NONE;
+}
+
+
+int wifi_direct_get_config_data(wifi_direct_config_data_s ** config)
+{
+ wifi_direct_client_info_s *client_info = __wfd_get_control();
+
+ __WFD_CLIENT_FUNC_START__;
+
+ if ((client_info->is_registered == false)
+ || (client_info->client_id == WFD_INVALID_ID))
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Client is NOT registered.\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_NOT_INITIALIZED;
+ }
+
+ if (config == NULL)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "NULL Param [config]!\n");
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_INVALID_PARAMETER;
+ }
+
+ wifi_direct_client_request_s req;
+ wifi_direct_client_response_s rsp;
+ wfd_config_data_s ls_config;
+
+ int status = WIFI_DIRECT_ERROR_NONE;
+
+ memset(&req, 0, sizeof(wifi_direct_client_request_s));
+ memset(&rsp, 0, sizeof(wifi_direct_client_response_s));
+
+ req.cmd = WIFI_DIRECT_CMD_GET_CONFIG;
+ req.client_id = client_info->client_id;
+
+ status =
+ __wfd_client_send_request(client_info->sync_sockfd, &req,
+ sizeof(wifi_direct_client_request_s));
+ if (status != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! writing to socket, Errno = %s\n",
+ strerror(errno));
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n",
+ __wfd_print_error(status));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+
+ if ((status =
+ __wfd_client_read_socket(client_info->sync_sockfd, (char *) &rsp,
+ sizeof(wifi_direct_client_response_s))) <= 0)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! reading socket, status = %d errno = %s\n",
+ status, strerror(errno));
+ client_info->sync_sockfd = -1;
+ __wfd_reset_control();
+ __WFD_CLIENT_FUNC_END__;
+ return WIFI_DIRECT_ERROR_COMMUNICATION_FAILED;
+ }
+ else
+ {
+ if (rsp.cmd == WIFI_DIRECT_CMD_GET_CONFIG)
+ {
+ if (rsp.result != WIFI_DIRECT_ERROR_NONE)
+ {
+ WFD_CLIENT_LOG(WFD_LOG_ERROR,
+ "Error!!! Result received = %d \n", rsp.result);
+ WFD_CLIENT_LOG(WFD_LOG_ERROR, "Error!!! [%s]\n",
+ __wfd_print_error(rsp.result));
+ __WFD_CLIENT_FUNC_END__;
+ return rsp.result;
+ }
+ else
+ {
+ int status = 0;
+
+ WFD_CLIENT_LOG(WFD_LOG_LOW, "Link status = %d \n",
+ (int) rsp.param1);
+
+ status =
+ __wfd_client_read_more_data(client_info->sync_sockfd,
+ &ls_config,
+ sizeof(wfd_config_data_s));
+ if (status != WIFI_DIRECT_ERROR_NONE)
+ {