924df3c0e2cfa3ae5ccdeb22081f494248c93dd4
[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 #ifdef IPSTR
59 #undef IPSTR
60 #define IPSTR "  %d.%d.%d.%d"
61 #endif /** IPSTR */
62
63 #define WIFI_DIRECT_MAX_SSID_LEN 32
64 #define WIFI_DIRECT_WPS_PIN_LEN 8
65
66
67 typedef enum
68 {
69         WIFI_DIRECT_CMD_INVALID,
70         WIFI_DIRECT_CMD_REGISTER,
71         WIFI_DIRECT_CMD_INIT_ASYNC_SOCKET,
72         WIFI_DIRECT_CMD_DEREGISTER,
73         WIFI_DIRECT_CMD_ACTIVATE,
74         WIFI_DIRECT_CMD_DEACTIVATE,
75         WIFI_DIRECT_CMD_START_DISCOVERY,
76         WIFI_DIRECT_CMD_CANCEL_DISCOVERY,
77         WIFI_DIRECT_CMD_GET_DISCOVERY_RESULT,
78         WIFI_DIRECT_CMD_GET_LINK_STATUS,
79         WIFI_DIRECT_CMD_CONNECT,
80         WIFI_DIRECT_CMD_DISCONNECT_ALL,
81         WIFI_DIRECT_CMD_CREATE_GROUP,
82         WIFI_DIRECT_CMD_IS_GROUPOWNER,
83         WIFI_DIRECT_CMD_GET_SSID,
84         WIFI_DIRECT_CMD_SET_SSID,
85         WIFI_DIRECT_CMD_GET_IP_ADDR,
86         WIFI_DIRECT_CMD_GET_CONFIG,
87         WIFI_DIRECT_CMD_SET_CONFIG,
88         WIFI_DIRECT_CMD_SEND_PROVISION_DISCOVERY_REQ,
89         WIFI_DIRECT_CMD_SEND_CONNECT_REQ,
90         WIFI_DIRECT_CMD_ACTIVATE_PUSHBUTTON,
91         WIFI_DIRECT_CMD_SET_WPS_PIN,
92         WIFI_DIRECT_CMD_GET_WPS_PIN,
93         WIFI_DIRECT_CMD_GENERATE_WPS_PIN,
94         WIFI_DIRECT_CMD_GET_INCOMMING_PEER_INFO,
95         WIFI_DIRECT_CMD_SET_WPA,
96         WIFI_DIRECT_CMD_GET_SUPPORTED_WPS_MODE,
97         WIFI_DIRECT_CMD_GET_CONNECTED_PEERS_INFO,
98         WIFI_DIRECT_CMD_CANCEL_GROUP,
99         WIFI_DIRECT_CMD_DISCONNECT,
100         WIFI_DIRECT_CMD_GET_GO_INTENT,
101         WIFI_DIRECT_CMD_GET_DEVICE_MAC,
102         WIFI_DIRECT_CMD_IS_AUTONOMOUS_GROUP,
103
104         WIFI_DIRECT_CMD_SET_OEM_LOGLEVEL,
105
106         WIFI_DIRECT_CMD_MAX
107 } wifi_direct_cmd_e;
108
109 /**
110  * Wi-Fi Direct client event for IPC
111  */
112 typedef enum
113 {
114         WIFI_DIRECT_CLI_EVENT_INVALID = -1,                                     /**< */
115
116         WIFI_DIRECT_CLI_EVENT_ACTIVATION,                                               /**< */
117         WIFI_DIRECT_CLI_EVENT_DEACTIVATION,                                     /**< */
118
119         WIFI_DIRECT_CLI_EVENT_DISCOVER_START,                           /**< 80211 scan*/
120         WIFI_DIRECT_CLI_EVENT_DISCOVER_START_LISTEN_ONLY,       /**< listen only mode*/
121         WIFI_DIRECT_CLI_EVENT_DISCOVER_START_SEARCH_LISTEN,     /**< search, listen*/
122         WIFI_DIRECT_CLI_EVENT_DISCOVER_END,                                     /**< */
123         WIFI_DIRECT_CLI_EVENT_DISCOVER_FOUND_PEERS,                     /**< */
124
125         WIFI_DIRECT_CLI_EVENT_CONNECTION_START,                         /**< */
126         WIFI_DIRECT_CLI_EVENT_CONNECTION_REQ,                           /**< */
127         WIFI_DIRECT_CLI_EVENT_CONNECTION_RSP,                           /**< */
128         WIFI_DIRECT_CLI_EVENT_CONNECTION_WPS_REQ,                       /**< */
129
130         WIFI_DIRECT_CLI_EVENT_DISCONNECTION_RSP,                                /**< */
131         WIFI_DIRECT_CLI_EVENT_DISCONNECTION_IND,                                /**< */
132         WIFI_DIRECT_CLI_EVENT_DISASSOCIATION_IND,                               /**< */
133
134         WIFI_DIRECT_CLI_EVENT_GROUP_CREATE_RSP,                         /**< */
135         WIFI_DIRECT_CLI_EVENT_GROUP_DESTROY_RSP,                                /**< */
136
137 } wfd_client_event_e;
138
139 /**
140  * Wi-Fi Direct configuration data structure for IPC
141  */
142 typedef struct
143 {
144         char ssid[WIFI_DIRECT_MAX_SSID_LEN + 1];
145         int channel;
146         wifi_direct_wps_cfg_e wps_config;
147         int max_clients;
148         bool hide_SSID;
149         int group_owner_intent;
150         bool want_persistent_group;
151         bool auto_connection;
152         wifi_direct_primary_device_type_e primary_dev_type;
153         wifi_direct_secondary_device_type_e secondary_dev_type;
154 } wfd_config_data_s;
155
156
157 /**
158  * Wi-Fi Direct buffer structure to store result of peer discovery for IPC
159  */
160 typedef struct
161 {
162         bool is_group_owner;
163         char ssid[WIFI_DIRECT_MAX_SSID_LEN + 1];
164         char mac_address[6];
165         int channel;
166         bool is_connected;
167         unsigned int services;
168         bool is_persistent_go;
169         char intf_mac_address[6];
170         unsigned int wps_device_pwd_id;
171         unsigned int wps_cfg_methods;
172         unsigned int category;
173         unsigned int subcategory;
174 } wfd_discovery_entry_s;
175
176
177 /**
178  * Wi-Fi Direct buffer structure to store information of connected peer
179  */
180 typedef struct
181 {
182         char ssid[WIFI_DIRECT_MAX_SSID_LEN + 1];
183         char mac_address[6];
184         char intf_mac_address[6];
185         unsigned int services;
186         bool is_p2p;
187         unsigned short category;
188 } wfd_connected_peer_info_s;
189
190
191 typedef struct
192 {
193         bool listen_only;
194         int timeout;
195
196         int peer_index;
197         char mac_addr[6];
198
199 } wifi_direct_client_request_data_s;
200
201
202 typedef struct
203 {
204         wifi_direct_cmd_e cmd;
205         int client_id;
206         wifi_direct_client_request_data_s data;
207 } wifi_direct_client_request_s;
208
209 typedef struct
210 {
211         wifi_direct_cmd_e cmd;
212         wifi_direct_error_e result;
213         int client_id;
214         int param1;
215         char param2[64];
216         char param3[32];
217         int data_length;
218 } wifi_direct_client_response_s;
219
220 typedef struct
221 {
222         wfd_client_event_e event;
223         wifi_direct_error_e error;
224         char param1[64];
225         char param2[64];
226 } wifi_direct_client_noti_s;
227
228
229 #endif                                                  //__WIFI_DIRECT_INTERNAL_H_