+wfi-direct-manager (0.5.8) precise; urgency=low
+
+ * Fix bug(N_SE-22984)
+ * Git : framework/connectivity/wifi-direct-manager
+ * Tag : wifi-direct-manager_0.5.8
+
+ -- Gibyoung Kim <lastkgb.kim@samsung.com> Fri, 25 Jan 2013 16:37:42 +0900
+
wfi-direct-manager (0.5.7) precise; urgency=low
* Fix bug(N_SE-21973)
Name: wifi-direct-manager
Summary: Wi-Fi Direct manger
-Version: 0.5.7
+Version: 0.5.8
Release: 1
Group: TO_BE_FILLED
License: Samsung Proprietary License
BuildRequires: cmake
-#%define debug_package %{nil}
%description
Wi-Fi Direct manager
case WS_EVENT_GO_NEG_REQUEST:
{
WDP_LOGD( "WS EVENT : [WS_EVENT_GO_NEG_REQUEST]");
- // TODO: check validity of event
- int wpa_mode;
- wfd_server_control_t *wfd_server = wfd_server_get_control();
event->id = WS_EVENT_GO_NEG_REQUEST;
ptr = __get_event_str(ptr + 19, event_str);
strncpy(event->peer_intf_mac_address, event_str, sizeof(event->peer_intf_mac_address));
char cmd[50] = {0, };
char mac_str[18] = {0, };
- char wps_str[8] = {0, };
char res_buffer[1024]={0,};
int res_buffer_len = sizeof(res_buffer);
int result;
char cmd[64] = {0, };
char mac_str[18] = {0, };
- char wps_str[8] = {0, };
char res_buffer[1024]={0,};
int res_buffer_len = sizeof(res_buffer);
int result;
/*
typedef struct
{
- char ssid[WIFI_DIRECT_MAX_SSID_LEN + 1];
+ char device_name[WIFI_DIRECT_MAX_DEVICE_NAME_LEN + 1];
+ unsigned char ip_address[4];
unsigned char mac_address[6];
unsigned char intf_mac_address[6];
unsigned int services;
int channel;
} wfd_connected_peer_info_s;
*/
+
result = __extract_value_str(res_buffer, "device_name", (char*) tmp_peer_list[i].device_name);
- if(result <= 0)
- {
+ if(result <= 0) {
WDP_LOGE( "Extracting value failed\n");
*peer_list = NULL;
*peer_num = 0;
}
-int wfd_server_send_response(int sockfd, void * data, int len)
+int wfd_server_send_response(int sockfd, void *data, int len)
{
int ret_val = 0;
- wfd_server_control_t * wfd_server = wfd_server_get_control();
- wifi_direct_client_response_s* resp = (wifi_direct_client_response_s*) data;
+ wfd_server_control_t *wfd_server = wfd_server_get_control();
+ wifi_direct_client_response_s *resp = (wifi_direct_client_response_s*) data;
__WDS_LOG_FUNC_ENTER__;
wfd_server_send_response(client->sync_sockfd, &resp, sizeof(wifi_direct_client_response_s));
int res = 0;
- wifi_direct_client_noti_s noti;
+ wifi_direct_client_noti_s noti;
memset(¬i, 0, sizeof(wifi_direct_client_noti_s));
noti.event = WIFI_DIRECT_CLI_EVENT_ACTIVATION;
// Initialize server db.
{
int i = -1;
- unsigned char NULL_MAC[6] = {0,0,0,0,0,0};
for(i=0;i<WFD_MAX_ASSOC_STA;i++)
{
memset(&wfd_server->connected_peers[i], 0, sizeof(wfd_local_connected_peer_info_t));
wfd_server->connected_peers[i].isUsed = 0;
}
wfd_server->connected_peer_count = 0;
- memcpy(wfd_server->current_peer.mac_address, NULL_MAC, 6);
+ memset(&wfd_server->current_peer, 0x00, sizeof(wfd_discovery_entry_s));
}
wfd_server_set_state(WIFI_DIRECT_STATE_ACTIVATING);
}
else
{
- sprintf(resp.param2, ssid);
+ snprintf(resp.param2, sizeof(resp.param2), "%s", ssid);
resp.result = WIFI_DIRECT_ERROR_NONE;
}
char device_name[WIFI_DIRECT_MAX_DEVICE_NAME_LEN+1];
strncpy(device_name, wfd_server->config_data.device_name, WIFI_DIRECT_MAX_DEVICE_NAME_LEN);
- sprintf(resp.param2, device_name);
+ snprintf(resp.param2, sizeof(resp.param2), "%s", device_name);
resp.result = WIFI_DIRECT_ERROR_NONE;
if (wfd_server_send_response(client->sync_sockfd, &resp, sizeof(wifi_direct_client_response_s)) < 0)
case WIFI_DIRECT_CMD_GET_IP_ADDR:
{
char* ip_addr = wfd_oem_get_ip();
- sprintf(resp.param2, ip_addr);
+ snprintf(resp.param2, sizeof(resp.param2), "%s", ip_addr);
resp.result = WIFI_DIRECT_ERROR_NONE;
if (wfd_server_send_response(client->sync_sockfd, &resp, sizeof(wifi_direct_client_response_s)) < 0)
else
{
WDS_LOGD( "pin [%s]\n", pin);
- sprintf(resp.param2, pin);
+ snprintf(resp.param2, sizeof(resp.param2), "%s", pin);
resp.result = WIFI_DIRECT_ERROR_NONE;
}
if (wfd_server_send_response(client->sync_sockfd, &resp, sizeof(wifi_direct_client_response_s)) < 0)
{
int total_msg_len = 0;
wfd_connected_peer_info_s* plist = NULL;
- wfd_connected_peer_info_s plist_buf;
- wfd_connected_peer_info_s* tmp_plist = NULL;
- wfd_local_connected_peer_info_t* tmplist = NULL;
int peer_count = 0;
- int i;
- int val = 0;
+ int i = 0, j = 0;
wifi_direct_state_e state = wfd_server_get_state();
ret = WIFI_DIRECT_ERROR_NONE;
- if (state == WIFI_DIRECT_STATE_CONNECTED)
- {
- val = wfd_oem_get_connected_peers_info(&tmp_plist, &peer_count);
- if (val == false)
- {
- WDS_LOGE( "Error!! wfd_oem_get_connected_peers_info() failed..\n");
- peer_count = 0;
- tmp_plist = NULL;
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ if (state < WIFI_DIRECT_STATE_CONNECTED) {
+ WDS_LOGE( "state != WIFI_DIRECT_STATE_CONNECTED\n");
+ resp.result = WIFI_DIRECT_ERROR_NOT_PERMITTED;
+ if (wfd_server_send_response(client->sync_sockfd, &resp,
+ sizeof(wifi_direct_client_response_s)) < 0) {
+ wfd_server_reset_client(client->sync_sockfd);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
}
- else
- {
- tmplist = wfd_server_get_connected_peer_by_interface_mac(tmp_plist[0].intf_mac_address);
- if (tmplist == NULL)
- {
- WDS_LOGE( "Error!! Can't find connected peer info of mac=[" MACSTR "]\n",
- MAC2STR(tmp_plist[0].intf_mac_address));
- peer_count = 0;
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- else
- {
- memset(&plist_buf, 0, sizeof(plist_buf));
- strncpy(plist_buf.device_name, tmplist->peer.device_name, sizeof(plist_buf.device_name));
- memcpy(&plist_buf.intf_mac_address[0], &tmplist->int_address[0], 6);
- memcpy(&plist_buf.mac_address[0], &tmplist->peer.mac_address[0], 6);
- plist_buf.services = tmplist->peer.services;
- plist_buf.is_p2p = 1;
- plist_buf.category = tmplist->peer.category;
- plist_buf.channel = wfd_oem_get_operating_channel();
- memcpy(&plist_buf.ip_address[0], &tmplist->ip_address[0], 4);
-
- plist = &plist_buf;
- peer_count = 1;
- }
+ break;
+
+ }
+ WDS_LOGD("WFD status [%d]", state);
+
+ peer_count = wfd_server->connected_peer_count;
+ if (peer_count <= 0) {
+ WDS_LOGE("Error?? There is no connected peers");
+ resp.result = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ if (wfd_server_send_response(client->sync_sockfd, &resp,
+ sizeof(wifi_direct_client_response_s)) < 0) {
+ wfd_server_reset_client(client->sync_sockfd);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
}
+ break;
}
- else if (state == WIFI_DIRECT_STATE_GROUP_OWNER)
+ WDS_LOGD("Connected peer count [%d]", peer_count);
+
+ plist = (wfd_connected_peer_info_s*) calloc(peer_count, sizeof(wfd_connected_peer_info_s));
+ if(plist == NULL)
{
- val = wfd_oem_get_connected_peers_info(&plist, &peer_count);
- if (val == false)
- {
- WDS_LOGE( "Error!! wfd_oem_get_connected_peers_info() failed..\n");
- ret = WIFI_DIRECT_ERROR_OPERATION_FAILED;
- }
- else
- {
- // Append Device MAC address
- for(i=0;i<peer_count;i++)
- {
- tmplist = wfd_server_get_connected_peer_by_interface_mac(plist[i].intf_mac_address);
- if (tmplist != NULL)
- {
- memcpy(&plist[i].mac_address[0], &tmplist->peer.mac_address[0], 6);
- memcpy(&plist[i].ip_address[0], &tmplist->ip_address[0], 4);
- }
- else
- {
- WDS_LOGE( "Error, Cant' find connected peer by int_addr" MACSTR "!!\n",
- MAC2STR(plist[i].intf_mac_address));
- // continue...
- }
- }
+ WDS_LOGF( "Memory Allocation is FAILED!!!!!![%d]\n");
+ resp.result = WIFI_DIRECT_ERROR_OPERATION_FAILED;
+ if (wfd_server_send_response(client->sync_sockfd, &resp,
+ sizeof(wifi_direct_client_response_s)) < 0) {
+ wfd_server_reset_client(client->sync_sockfd);
+ __WDS_LOG_FUNC_EXIT__;
+ return;
}
+ break;
}
- else
+
+ while(j < peer_count && i < WFD_MAX_ASSOC_STA)
{
- plist = NULL;
- peer_count = 0;
- WDS_LOGE( "state != WIFI_DIRECT_STATE_CONNECTED\n");
- ret = WIFI_DIRECT_ERROR_NOT_PERMITTED;
- }
+ if (wfd_server->connected_peers[i].isUsed == 0) {
+ WDS_LOGD("Not used peer info [%s]", wfd_server->connected_peers[i].peer.device_name);
+ i++;
+ continue;
+ }
+ WDS_LOGD("Connected peer info found [%s]", wfd_server->connected_peers[i].peer.device_name);
+
+ strncpy(plist[j].device_name, wfd_server->connected_peers[i].peer.device_name, WIFI_DIRECT_MAX_DEVICE_NAME_LEN);
+ memcpy(&plist[j].intf_mac_address[0], wfd_server->connected_peers[i].int_address, 6);
+ memcpy(&plist[j].mac_address[0], wfd_server->connected_peers[i].peer.mac_address, 6);
+ plist[j].services = wfd_server->connected_peers[i].peer.services;
+ plist[j].is_p2p = 1;
+ plist[j].category = wfd_server->connected_peers[i].peer.category;
+ plist[j].channel = wfd_server->connected_peers[i].peer.channel;
+ memcpy(&plist[j].ip_address[0], wfd_server->connected_peers[i].ip_address, 4);
+ j++;
+ }
total_msg_len = sizeof(wifi_direct_client_response_s) + (sizeof(wfd_connected_peer_info_s) * peer_count);
WDS_LOGD( "Peer count : %d, total message size : %d\n", peer_count, total_msg_len);
}
resp.param1 = peer_count;
-#if 0
- if (ret == TRUE)
- resp.result = WIFI_DIRECT_ERROR_NONE;
-#else
resp.result = ret;
-#endif
memset(msg, 0, total_msg_len);
memcpy(msg, &resp, sizeof(wifi_direct_client_response_s));
#include <glib.h>
#include <errno.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <unistd.h>
continue;
}
wfd_macaddr_atoe(mac_str, mac_hex);
- __wfd_server_print_connected_peer();
for(i=0; i<WFD_MAX_ASSOC_STA; i++)
{
if (wfd_server->connected_peers[i].isUsed == 1 &&
memcmp(mac_hex, wfd_server->connected_peers[i].int_address, 6) == 0)
{
- WDS_LOGD( "Found peer: interface mac=[%s].\n",mac_str);
- WDS_LOGD( "device mac=["MACSTR"]\n",MAC2STR(wfd_server->connected_peers[i].peer.mac_address));
+ WDS_LOGD( "Found peer: interface mac=[%s].\n",mac_str);
+ WDS_LOGD( "device mac=["MACSTR"]\n",MAC2STR(wfd_server->connected_peers[i].peer.mac_address));
- inet_aton(ip_str, (struct in_addr*)&wfd_server->connected_peers[i].ip_address);
- WDS_LOGD( "Fill IP: ip=[%s].\n",ip_str);
+ inet_aton(ip_str, (struct in_addr*)&wfd_server->connected_peers[i].ip_address);
+ WDS_LOGD( "Fill IP: ip=[%s].\n",ip_str);
- //Send event to client with [dev_mac, ip]
- noti.event = WIFI_DIRECT_CLI_EVENT_IP_LEASED_IND;
- snprintf(noti.param1, 18, MACSTR, MAC2STR(wfd_server->connected_peers[i].peer.mac_address));
- strncpy(noti.param2, ip_str, strlen(ip_str));
- __wfd_server_send_client_event(¬i);
+ //Send event to client with [dev_mac, ip]
+ noti.event = WIFI_DIRECT_CLI_EVENT_IP_LEASED_IND;
+ snprintf(noti.param1, 18, MACSTR, MAC2STR(wfd_server->connected_peers[i].peer.mac_address));
+ strncpy(noti.param2, ip_str, strlen(ip_str));
+ __wfd_server_send_client_event(¬i);
break;
}
}
\r
#include <errno.h>\r
#include <stdio.h>\r
+#include <stdlib.h>\r
#include <string.h>\r
#include <stdbool.h>\r
#include <sys/types.h>\r
+#include <sys/socket.h>\r
#include <unistd.h>\r
\r
+#include <glib.h>\r
+\r
#include "wifi-direct-service.h"\r
#include "wifi-direct-event-handler.h"\r
#include "wifi-direct-oem.h"\r
\r
#endif\r
\r
- wfd_server->dhcp_ip_address_timer = g_timeout_add(1000, __wfd_get_ip_address, NULL);\r
+ wfd_server->dhcp_ip_address_timer = g_timeout_add(1000, (GSourceFunc) __wfd_get_ip_address, NULL);\r
}\r
\r
void wfd_server_cancel_dhcp_wait_timer()\r
\r
wfd_server_control_t *wfd_server = wfd_server_get_control();\r
int i;\r
- unsigned char NULL_IP[4] = { 0, 0, 0, 0};\r
\r
for (i = 0; i < WFD_MAX_ASSOC_STA; i++)\r
{\r
{\r
wfd_server->connected_peers[i].isUsed = 0;\r
wfd_server->connected_peer_count--;\r
- memcpy(wfd_server->connected_peers[i].ip_address, NULL_IP, 4);\r
+ memset(&wfd_server->connected_peers[i], 0x00, sizeof(wfd_local_connected_peer_info_t));\r
break;\r
}\r
}\r
\r
wfd_server_control_t *wfd_server = wfd_server_get_control();\r
int i;\r
- unsigned char NULL_IP[4] = { 0, 0, 0, 0};\r
\r
for (i = 0; i < WFD_MAX_ASSOC_STA; i++)\r
{\r
{\r
wfd_server->connected_peers[i].isUsed = 0;\r
wfd_server->connected_peer_count--;\r
- memcpy(wfd_server->connected_peers[i].ip_address, NULL_IP, 4);\r
+ memset(&wfd_server->connected_peers[i], 0x00, sizeof(wfd_local_connected_peer_info_t));\r
break;\r
}\r
}\r
wfd_server_get_connected_peer_by_interface_mac(interface_mac);\r
if (peer != NULL)\r
{\r
- WDS_LOGI(\r
- "Peer's Intf MAC: " MACSTR ", Device MAC:" MACSTR " \n",\r
- MAC2STR(interface_mac),\r
- MAC2STR(peer->peer.mac_address));\r
+ WDS_LOGI("Peer's Intf MAC: " MACSTR ", Device MAC:" MACSTR " \n",\r
+ MAC2STR(interface_mac),\r
+ MAC2STR(peer->peer.mac_address));\r
snprintf(noti.param1, sizeof(noti.param1), MACSTR,\r
MAC2STR(peer->peer.mac_address));\r
}\r
else\r
{\r
- WDS_LOGI(\r
- "Peer's Intf MAC: " MACSTR ", Device MAC:null \n",\r
- MAC2STR(interface_mac));\r
+ WDS_LOGI("Peer's Intf MAC: " MACSTR ", Device MAC:null \n",\r
+ MAC2STR(interface_mac));\r
memset(noti.param1, 0, 6);\r
}\r
\r
wfd_server->config_data.wps_config =\r
WIFI_DIRECT_WPS_TYPE_PBC;\r
if (wfd_oem_disconnect() == false)\r
- {\r
- WDS_LOGF(\r
- "Error!!! wfd_oem_disconnect() failed!!..\n");\r
- }\r
+ WDS_LOGF("Error!!! wfd_oem_disconnect() failed!!..\n");\r
}\r
noti.event = WIFI_DIRECT_CLI_EVENT_DISASSOCIATION_IND;\r
__wfd_server_send_client_event(¬i);\r
}\r
else\r
{\r
- WDS_LOGF(\r
- "Error!!! DISASSOC event come..\n");\r
+ WDS_LOGF("Error!!! DISASSOC event come..\n");\r
}\r
}\r
break;\r
\r
case WFD_EVENT_PRIMARY_IF_DISCONNECTION:\r
- WDS_LOGD(\r
- "Primary interface (wlan0) is down. Just let it up!\n");\r
+ WDS_LOGD("Primary interface (wlan0) is down. Just let it up!\n");\r
system("ifconfig wlan0 up");\r
break;\r
\r
"Peer's Dev MAC is " MACSTR "\n",\r
MAC2STR(wfd_server->current_peer.\r
mac_address));\r
- //WDS_LOGI( "Peer's SSID is [%s]\n", wfd_server->current_peer.ssid);\r
snprintf(noti.param1, sizeof(noti.param1), MACSTR,\r
MAC2STR(wfd_server->current_peer.mac_address));\r
- //strncpy(noti.param2, wfd_server->current_peer.ssid, strlen(wfd_server->current_peer.ssid));\r
\r
- wfd_server_clear_connected_peer();\r
- wfd_server->config_data.wps_config =\r
- WIFI_DIRECT_WPS_TYPE_PBC;\r
+ wfd_server->config_data.wps_config = WIFI_DIRECT_WPS_TYPE_PBC;\r
noti.event = WIFI_DIRECT_CLI_EVENT_DISCONNECTION_IND;\r
__wfd_server_send_client_event(¬i);\r
wfd_server_set_state(WIFI_DIRECT_STATE_ACTIVATED);\r
}\r
else\r
{\r
- WDS_LOGD(\r
- "message is ignored [%d] at state=[%d]\n",\r
- event, state);\r
+ WDS_LOGD("message is ignored [%d] at state=[%d]\n",\r
+ event, state);\r
}\r
+ wfd_server_clear_connected_peer();\r
+\r
}\r
break;\r
case WFD_EVENT_CREATE_LINK_DOWN:\r
{\r
- if (state == WIFI_DIRECT_STATE_CONNECTED)\r
+ if (state >= WIFI_DIRECT_STATE_CONNECTED)\r
{\r
WDS_LOGI(\r
"Peer's Intf MAC: " MACSTR ", Device MAC:" MACSTR " \n",\r
MAC2STR(wfd_server->connected_peers[0].peer.mac_address));\r
\r
wfd_server_clear_connected_peer();\r
- wfd_server->config_data.wps_config =\r
- WIFI_DIRECT_WPS_TYPE_PBC;\r
+ wfd_server->config_data.wps_config = WIFI_DIRECT_WPS_TYPE_PBC;\r
noti.event = WIFI_DIRECT_CLI_EVENT_DISCONNECTION_IND;\r
__wfd_server_send_client_event(¬i);\r
wfd_server_set_state(WIFI_DIRECT_STATE_ACTIVATED);\r
static int wfd_server_init(void)
{
__WDS_LOG_FUNC_ENTER__;
- int i = -1;
memset(&g_wfd_server, 0x00, sizeof(wfd_server_control_t));
g_wfd_server.async_sockfd = -1;
{
__WDS_LOG_FUNC_ENTER__;
wfd_server_control_t *wfd_server = wfd_server_get_control();
- wifi_direct_client_noti_s noti;
int ret;
g_source_remove(wfd_server->discovery_timer);
WDS_LOGE( "Error!! wfd_oem_cancel_discovery() failed..\n");
}
-#if 0
- memset(¬i, 0, sizeof(wifi_direct_client_noti_s));
-
- noti.event = WIFI_DIRECT_CLI_EVENT_DISCOVER_END;
- noti.error = WIFI_DIRECT_ERROR_NONE;
-
- __wfd_server_send_client_event(¬i);
-#endif
-
__WDS_LOG_FUNC_EXIT__;
return FALSE;
}