tizen 2.0beta
[framework/connectivity/libwifi-direct.git] / include / wifi-direct-internal.h
1 /*
2  * libwifi-direct
3  *
4  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Sungsik Jang <sungsik.jang@samsung.com>, Dongwook Lee <dwmax.lee@samsung.com> 
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef __WIFI_DIRECT_INTERNAL_H_
23 #define __WIFI_DIRECT_INTERNAL_H_
24
25 #include "wifi-direct.h"
26
27
28 #define true 1
29 #define false 0
30
31 #define WFD_INVALID_ID  -1
32
33
34 #ifndef O_NONBLOCK
35 #define O_NONBLOCK  O_NDELAY
36 #endif /** O_NONBLOCK */
37
38
39 #ifndef _UINT32_TYPE_H_
40 #define _UINT32_TYPE_H_
41 typedef unsigned int uint32;
42 #endif /** _UINT32_TYPE_H_ */
43
44 typedef unsigned int ipv4_addr_t;
45
46 #ifndef TRUE
47 #define TRUE 1
48 #endif /** TRUE */
49
50 #ifndef FALSE
51 #define FALSE 0
52 #endif /** FALSE */
53
54 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
55 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
56 #define IP2STR(a) (a)[0], (a)[1], (a)[2], (a)[3]
57
58 #define IPSTR "%d.%d.%d.%d"
59
60 #define WIFI_DIRECT_MAX_SSID_LEN 32
61 #define WIFI_DIRECT_WPS_PIN_LEN 8
62 #define WIFI_DIRECT_MAC_ADDRESS_INFO_FILE "/opt/etc/.mac.info"
63
64 #define VCONFKEY_IFNAME "memory/private/wifi_direct_manager/p2p_ifname"
65 #define VCONFKEY_LOCAL_IP "memory/private/wifi_direct_manager/p2p_local_ip"
66 #define VCONFKEY_SUBNET_MASK "memory/private/wifi_direct_manager/p2p_subnet_mask"
67 #define VCONFKEY_GATEWAY "memory/private/wifi_direct_manager/p2p_gateway"
68
69 typedef enum
70 {
71         WIFI_DIRECT_CMD_INVALID,
72         WIFI_DIRECT_CMD_REGISTER,
73         WIFI_DIRECT_CMD_INIT_ASYNC_SOCKET,
74         WIFI_DIRECT_CMD_DEREGISTER,
75         WIFI_DIRECT_CMD_ACTIVATE,
76         WIFI_DIRECT_CMD_DEACTIVATE,
77         WIFI_DIRECT_CMD_START_DISCOVERY,
78         WIFI_DIRECT_CMD_CANCEL_DISCOVERY,
79         WIFI_DIRECT_CMD_GET_DISCOVERY_RESULT,
80         WIFI_DIRECT_CMD_GET_LINK_STATUS,
81         WIFI_DIRECT_CMD_CONNECT,
82         WIFI_DIRECT_CMD_DISCONNECT_ALL,
83         WIFI_DIRECT_CMD_CREATE_GROUP,
84         WIFI_DIRECT_CMD_IS_GROUPOWNER,
85         WIFI_DIRECT_CMD_GET_SSID,
86         WIFI_DIRECT_CMD_SET_SSID,
87         WIFI_DIRECT_CMD_GET_IP_ADDR,
88         WIFI_DIRECT_CMD_GET_CONFIG,
89         WIFI_DIRECT_CMD_SET_CONFIG,
90         WIFI_DIRECT_CMD_SEND_PROVISION_DISCOVERY_REQ,
91         WIFI_DIRECT_CMD_SEND_CONNECT_REQ,
92         WIFI_DIRECT_CMD_ACTIVATE_PUSHBUTTON,
93         WIFI_DIRECT_CMD_SET_WPS_PIN,
94         WIFI_DIRECT_CMD_GET_WPS_PIN,
95         WIFI_DIRECT_CMD_GENERATE_WPS_PIN,
96         WIFI_DIRECT_CMD_GET_INCOMMING_PEER_INFO,
97         WIFI_DIRECT_CMD_SET_WPA,
98         WIFI_DIRECT_CMD_GET_SUPPORTED_WPS_MODE,
99         WIFI_DIRECT_CMD_SET_CURRENT_WPS_MODE,
100         WIFI_DIRECT_CMD_GET_CONNECTED_PEERS_INFO,
101         WIFI_DIRECT_CMD_CANCEL_GROUP,
102         WIFI_DIRECT_CMD_DISCONNECT,
103         WIFI_DIRECT_CMD_SET_GO_INTENT,
104         WIFI_DIRECT_CMD_GET_GO_INTENT,
105         WIFI_DIRECT_CMD_GET_DEVICE_MAC,
106         WIFI_DIRECT_CMD_IS_AUTONOMOUS_GROUP,
107         WIFI_DIRECT_CMD_SET_MAX_CLIENT,
108         WIFI_DIRECT_CMD_GET_MAX_CLIENT,
109         WIFI_DIRECT_CMD_SET_AUTOCONNECTION_MODE,
110         WIFI_DIRECT_CMD_IS_DISCOVERABLE,
111         WIFI_DIRECT_CMD_GET_OWN_GROUP_CHANNEL,
112         
113         WIFI_DIRECT_CMD_SET_OEM_LOGLEVEL,
114
115         WIFI_DIRECT_CMD_MAX
116 } wifi_direct_cmd_e;
117
118 /**
119  * Wi-Fi Direct client event for IPC
120  */
121 typedef enum
122 {
123         WIFI_DIRECT_CLI_EVENT_INVALID = -1,                                     /**< */
124
125         WIFI_DIRECT_CLI_EVENT_ACTIVATION,                                               /**< */
126         WIFI_DIRECT_CLI_EVENT_DEACTIVATION,                                     /**< */
127
128         WIFI_DIRECT_CLI_EVENT_DISCOVER_START,                           /**< 80211 scan*/
129         WIFI_DIRECT_CLI_EVENT_DISCOVER_START_LISTEN_ONLY,       /**< listen only mode*/
130         WIFI_DIRECT_CLI_EVENT_DISCOVER_START_SEARCH_LISTEN,     /**< search, listen*/
131         WIFI_DIRECT_CLI_EVENT_DISCOVER_END,                                     /**< */
132         WIFI_DIRECT_CLI_EVENT_DISCOVER_FOUND_PEERS,                     /**< */
133
134         WIFI_DIRECT_CLI_EVENT_CONNECTION_START,                         /**< */
135         WIFI_DIRECT_CLI_EVENT_CONNECTION_REQ,                           /**< */
136         WIFI_DIRECT_CLI_EVENT_CONNECTION_RSP,                           /**< */
137         WIFI_DIRECT_CLI_EVENT_CONNECTION_WPS_REQ,                       /**< */
138
139         WIFI_DIRECT_CLI_EVENT_DISCONNECTION_RSP,                                /**< */
140         WIFI_DIRECT_CLI_EVENT_DISCONNECTION_IND,                                /**< */
141         WIFI_DIRECT_CLI_EVENT_DISASSOCIATION_IND,                               /**< */
142
143         WIFI_DIRECT_CLI_EVENT_GROUP_CREATE_RSP,                         /**< */
144         WIFI_DIRECT_CLI_EVENT_GROUP_DESTROY_RSP,                                /**< */
145
146         WIFI_DIRECT_CLI_EVENT_IP_LEASED_IND,                            /**< */
147 } wfd_client_event_e;
148
149 /**
150  * Wi-Fi Direct configuration data structure for IPC
151  */
152 typedef struct
153 {
154         char ssid[WIFI_DIRECT_MAX_SSID_LEN + 1];
155         int channel;
156         wifi_direct_wps_type_e wps_config;
157         int max_clients;
158         bool hide_SSID;
159         int group_owner_intent;
160         bool want_persistent_group;
161         bool auto_connection;
162         wifi_direct_primary_device_type_e primary_dev_type;
163         wifi_direct_secondary_device_type_e secondary_dev_type;
164 } wfd_config_data_s;
165
166
167 /**
168  * Wi-Fi Direct buffer structure to store result of peer discovery for IPC
169  */
170 typedef struct
171 {
172         bool is_group_owner;
173         char ssid[WIFI_DIRECT_MAX_SSID_LEN + 1];
174         unsigned char mac_address[6];
175         int channel;
176         bool is_connected;
177         unsigned int services;
178         bool is_persistent_go;
179         unsigned char intf_mac_address[6];
180         unsigned int wps_device_pwd_id;
181         unsigned int wps_cfg_methods;
182         unsigned int category;
183         unsigned int subcategory;
184         bool is_wfd_device      ;
185 } wfd_discovery_entry_s;
186
187
188 /**
189  * Wi-Fi Direct buffer structure to store information of connected peer
190  */
191 typedef struct
192 {
193         char ssid[WIFI_DIRECT_MAX_SSID_LEN + 1];
194         unsigned char ip_address[4];
195         unsigned char mac_address[6];
196         unsigned char intf_mac_address[6];
197         unsigned int services;
198         bool is_p2p;
199         unsigned short category;
200         int channel;
201 } wfd_connected_peer_info_s;
202
203
204 typedef struct
205 {
206         bool listen_only;
207         int timeout;
208
209         int peer_index;
210         unsigned char mac_addr[6];
211
212 } wifi_direct_client_request_data_s;
213
214
215 typedef struct
216 {
217         wifi_direct_cmd_e cmd;
218         int client_id;
219         wifi_direct_client_request_data_s data;
220 } wifi_direct_client_request_s;
221
222 typedef struct
223 {
224         wifi_direct_cmd_e cmd;
225         wifi_direct_error_e result;
226         int client_id;
227         int param1;
228         char param2[64];
229         char param3[32];
230         int data_length;
231 } wifi_direct_client_response_s;
232
233 typedef struct
234 {
235         wfd_client_event_e event;
236         wifi_direct_error_e error;
237         char param1[64];
238         char param2[64];
239 } wifi_direct_client_noti_s;
240
241
242 #endif                                                  //__WIFI_DIRECT_INTERNAL_H_