Remove the TIZEN_FEATURE_ASP build flag
[platform/core/connectivity/wifi-direct-manager.git] / plugin / wpasupplicant / ctrl_iface_dbus / include / wfd-plugin-wpasupplicant.h
1 /*
2  * Network Configuration Module
3  *
4  * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 /**
21  * This file declares wifi direct wpasupplicant plugin functions and structures.
22  *
23  * @file                wfd-plugin-wpasupplicant.h
24  * @author      Gibyoung Kim (lastkgb.kim@samsung.com)
25  * @version     0.7
26  */
27
28 #ifndef __WFD_PLUGIN_WPASUPPLICANT_H__
29 #define __WFD_PLUGIN_WPASUPPLICANT_H__
30
31
32 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
33 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
34 #define IP2STR(a) (a)[0], (a)[1], (a)[2], (a)[3]
35 #define IPSTR "%d.%d.%d.%d"
36 #define MAC2SECSTR(a) (a)[0], (a)[4], (a)[5]
37 #define MACSECSTR "%02x:%02x:%02x"
38 #define ISZEROMACADDR(a) !(a[0] | a[1] | a[2] | a[3] | a[4] | a[5])
39 #define IP2SECSTR(a) (a)[0], (a)[3]
40 #define IPSECSTR "%d..%d"
41 #define OBJECT_PATH_MAX 150
42 #define MAX_SIZE_ERROR_BUFFER 256
43
44 #if defined(TIZEN_PROFILE_MOBILE) || defined(TIZEN_PROFILE_COMMON)
45 #define COMMON_IFACE_NAME "wlan0"
46
47 #       if defined TIZEN_WLAN_BOARD_SPRD
48 #               define P2P_IFACE_NAME "p2p0"
49 #               define GROUP_IFACE_NAME "p2p0"
50 #               define GROUP_IFACE_PREFIX "p2p"
51 #       else /* TIZEN_WLAN_BOARD_SPRD */
52 #               define GROUP_IFACE_NAME "p2p-wlan0-0"
53 #               define GROUP_IFACE_PREFIX "p2p-wlan0-"
54 #       endif /* TIZEN_WLAN_BOARD_SPRD */
55
56 #       define PRIMARY_DEVICE_TYPE "\x00\x0a\x00\x50\xf2\x04\x00\x05"
57 #       define DEFAULT_DEVICE_NAME "Tizen"
58 #       define DEFAULT_GO_INTENT 7
59 #       define DEFAULT_PERSISTENT_RECONNECT 1
60 #       define DEFAULT_LISTEN_REG_CLASS 81
61 #       define DEFAULT_LISTEN_CHANNEL 1
62 #       define DEFAULT_OPER_REG_CLASS 81
63 #       define DEFAULT_OPER_CHANNEL 1
64 #       define DEFAULT_CONFIG_METHOD "display push_button keypad p2ps"
65 #       define DEFAULT_NO_GROUP_IFACE 0
66 #endif /* TIZEN_PROFILE_MOBILE */
67
68 #if defined TIZEN_PROFILE_TV
69
70 #       define COMMON_IFACE_NAME "p2p0"
71 #       define GROUP_IFACE_NAME "p2p0"
72 #       define GROUP_IFACE_PREFIX "p2p"
73
74 #       define PRIMARY_DEVICE_TYPE "\x00\x07\x00\x50\xf2\x04\x00\x01"
75 #       define DEFAULT_DEVICE_NAME "[TV]Tizen"
76 #       define DEFAULT_GO_INTENT 7
77 #       define DEFAULT_PERSISTENT_RECONNECT 1
78 #       define DEFAULT_LISTEN_REG_CLASS 81
79 #       define DEFAULT_LISTEN_CHANNEL 1
80 #       define DEFAULT_OPER_REG_CLASS 81
81 #       define DEFAULT_OPER_CHANNEL 1
82 #       define DEFAULT_CONFIG_METHOD "keypad virtual_push_button physical_display"
83 #       define DEFAULT_NO_GROUP_IFACE 1
84 #endif /* TIZEN_PROFILE_TV */
85
86 #if 0
87 #define COMMON_IFACE_NAME "p2p0"
88 #define DEFAULT_CONFIG_METHOD "push_button"
89 #define DEFAULT_NO_GROUP_IFACE 0
90 #define GROUP_IFACE_NAME "p2p0"
91 #define GROUP_IFACE_PREFIX "p2p"
92 #define PRIMARY_DEVICE_TYPE "\x00\x07\x00\x50\xf2\x04\x00\x01"
93 #define DEFAULT_DEVICE_NAME "[TV]Tizen"
94 #define DEFAULT_GO_INTENT 7
95 #define DEFAULT_PERSISTENT_RECONNECT 1
96 #define DEFAULT_LISTEN_REG_CLASS 81
97 #define DEFAULT_LISTEN_CHANNEL 1
98 #define DEFAULT_OPER_REG_CLASS 115
99 #define DEFAULT_OPER_CHANNEL 48
100 #define DEFAULT_CONFIG_METHOD "keypad virtual_push_button physical_display"
101 #define DEFAULT_NO_GROUP_IFACE 1
102 #endif
103
104 #ifdef TIZEN_FEATURE_IP_OVER_EAPOL
105 #define DEFAULT_IP_GO "\xc0\xa8\x31\x01"
106 #define DEFAULT_IP_MASK "\xff\xff\xff\x00"
107 #define DEFAULT_IP_START "\xc0\xa8\x31\x33"
108 #define DEFAULT_IP_END "\xc0\xa8\x31\x64"
109 #endif /* TIZEN_FEATURE_IP_OVER_EAPOL */
110
111 #define WS_POLL_TIMEOUT 5000
112 #define WS_CONN_RETRY_COUNT 10
113 #define WS_PINSTR_LEN 8
114 #define WS_SSID_LEN 32
115 #define WS_MACSTR_LEN 18
116 #define WS_MACADDR_LEN 6
117 #define WS_MAX_PERSISTENT_COUNT 20
118
119 #define WS_DEVTYPE_LEN 8
120
121 #define SERV_DISC_REQ_ALL "02000001"
122 #define SERV_DISC_REQ_BONJOUR "02000101"
123 #define SERV_DISC_REQ_UPNP "02000201"
124
125 #define SERVICE_TYPE_LEN 8
126 #define WS_MAX_SERVICE_LEN 1024
127 #define SERVICE_QUERY_LEN 4
128
129 #define SERVICE_TYPE_ALL "0000f00c"
130 #define SERV_BROADCAST_ADDRESS "00:00:00:00:00:00"
131
132 #define WS_QTYPE_PTR 0x0c
133 #define WS_QTYPE_TXT 0x10
134 #define WS_TCP_PTR_HEX "\xc0\x0c"
135 #define WS_UDP_PTR_HEX "\xc0\x1e"
136 #define WS_PTR_TYPE_HEX "\x00\x0c\x01"
137 #define WS_TXT_TYPE_HEX "\x00\x10\x01"
138
139 /* Config Method bitmap */
140 #define WS_CONFIG_METHOD_DISPLAY 0x0008
141 #define WS_CONFIG_METHOD_PUSHBUTTON 0x0080
142 #define WS_CONFIG_METHOD_KEYPAD 0x0100
143 #define WS_CONFIG_METHOD_P2PS 0x1000
144
145 #define WS_DBUS_STR_PBC "pbc"
146 #define WS_DBUS_STR_DISPLAY "display"
147 #define WS_DBUS_STR_KEYPAD "keypad"
148 #define WS_DBUS_STR_P2PS "p2ps"
149 #define WS_DBUS_STR_JOIN "join"
150 #define WS_DBUS_STR_AUTH "auth"
151 #define WS_DBUS_STR_PERSISTENT "persistent"
152
153 #define WS_WFD_INFO_PRIMARY_SINK 0x01
154 #define WS_WFD_INFO_SECONDARY_SINK 0x02
155 #define WS_WFD_INFO_AVAILABILITY 0x10
156 #define WS_WFD_INFO_WSD_SUPPORT 0x40
157 #define WS_WFD_INFO_TDLS_SUPPORT 0x80
158 #define WS_WFD_INFO_HDCP_SUPPORT 0x100
159 #define WS_WFD_INFO_SYNC_SUPPORT 0x200
160
161 typedef enum {
162         WS_IFTYPE_NONE,
163         WS_IFTYPE_STATION,
164         WS_IFTYPE_GROUP,
165 } ws_iftype_e;
166
167 typedef enum {
168         WS_PRI_DEV_TYPE_NONE,
169         WS_PRI_DEV_TYPE_COMPUTER = 1,
170         WS_PRI_DEV_TYPE_INPUT_DEVICE = 2,
171         WS_PRI_DEV_TYPE_PRINTER = 3,
172         WS_PRI_DEV_TYPE_CAMERA = 4,
173         WS_PRI_DEV_TYPE_STORAGE = 5,
174         WS_PRI_DEV_TYPE_NETWORK_INFRA = 6,
175         WS_PRI_DEV_TYPE_DISPLAY = 7,
176         WS_PRI_DEV_TYPE_MULTIMEDIA_DEVICE = 8,
177         WS_PRI_DEV_TYPE_GAME_DEVICE = 9,
178         WS_PRI_DEV_TYPE_TELEPHONE = 10,
179         WS_PRI_DEV_TYPE_AUDIO = 11,
180         WS_PRI_DEV_TYPE_OTHER = 255,
181 } ws_device_type_e;
182
183 typedef enum {
184         /* The Service Discovery field shall be set to 1
185          * if the P2P Device supports Service Discovery,
186          * and is set to 0 otherwise. */
187         WS_DEVICE_CAP_SERVICE_DISCOVERY = 0x01,
188
189         /* Within a P2P Group Info attribute and a (Re)association
190          * request frame the P2P Client Discoverability field shall be set to 1
191          * when the P2P Device supports P2P Client Discoverability,
192          * and is set to 0 otherwise.
193          * This field shall be reserved and set to 0 in all other frames or uses. */
194         WS_DEVICE_CAP_CLIENT_DISCOVERABILITY = 0x02,
195
196         /* The Concurrent Operation field shall be set to 1
197          * when the P2P Device supports Concurrent Operation with WLAN,
198          * and is set to 0 otherwise. */
199         WS_DEVICE_CAP_CONCURRENT_OPERATION = 0x04,
200
201         /* The P2P Infrastructure Managed field shall be set to 1
202          * when the P2P interface of the P2P Device is capable of being
203          * managed by the WLAN (infrastructure network) based on
204          * P2P Coexistence Parameters, and set to 0 otherwise. */
205         WS_DEVICE_CAP_INFRASTRUCTURE_MANAGED = 0x08,
206
207         /* The P2P Device Limit field shall be set to 1
208          * when the P2P Device is unable to participate in additional P2P Groups,
209          * and set to 0 otherwise. */
210         WS_DEVICE_CAP_DEVICE_LIMIT = 0x10,
211
212         /* The P2P Invitation Procedure field shall be set to 1
213          * if the P2P Device is capable of processing P2P Invitation Procedure
214          * signaling, and set to 0 otherwise. */
215         WS_DEVICE_CAP_INVITATION_PROCEDURE = 0x20,
216 } ws_device_cap_flag_e;
217
218 typedef enum {
219         /* The P2P Group Owner field shall be set to 1
220          * when the P2P Device is operating as a Group Owner,
221          * and set to 0 otherwise. */
222         WS_GROUP_CAP_GROUP_OWNER = 0x01,
223
224         /* The Persistent P2P Group field shall be set to 1
225          * when the P2P Device is hosting, or intends to host,
226          * a persistent P2P Group, and set to 0 otherwise. */
227         WS_GROUP_CAP_PERSISTENT_GROUP = 0x02,
228
229         /* The P2P Group Limit field shall be set to 1
230          * when the P2P Group Owner is unable to add additional Clients
231          * to its P2P Group, and set to 0 otherwise. */
232         WS_GROUP_CAP_GROUP_LIMIT = 0x04,
233
234         /* The Intra-BSS Distribution field shall be set to 1
235          * if the P2P Device is hosting, or intends to host,
236          * a P2P Group that provides a data distribution service
237          * between Clients in the P2P Group.
238          * The Intra-BSS Distribution field shall be set to 0,
239          * if the P2P Device is not a P2P Group Owner,
240          * or is not providing such a data distribution service. */
241         WS_GROUP_CAP_INTRA_BSS_DISTRIB = 0x08,
242
243         /* The Cross Connection field shall be set to 1
244          * if the P2P Device is hosting, or intends to host,
245          * a P2P Group that provides cross connection
246          * between the P2P Group and a WLAN.
247          * The Cross Connection field shall be set to 0
248          * if the P2P Device is not a P2P Group Owner,
249          * or is not providing a cross connection service. */
250         WS_GROUP_CAP_CROSS_CONNECTION = 0x10,
251
252         /* The Persistent Reconnect field shall be set to 1
253          * when the P2P Device is hosting, or intends to host,
254          * a persistent P2P Group that allows reconnection
255          * without user intervention, and set to 0 otherwise. */
256         WS_GROUP_CAP_PERSISTENT_RECONN = 0x20,
257
258         /* The Group Formation field shall be set to 1
259          * when the P2P Device is operating as a Group Owner
260          * in the Provisioning phase of Group Formation,
261          * and set to 0 otherwise. */
262         WS_GROUP_CAP_GROUP_FORMATION = 0x40,
263 } ws_group_cap_flag_e;
264
265 typedef enum {
266         /* If the Device Password ID is Default, the Enrollee should use
267          * its PIN password (from the label or display). This password may
268          * correspond to the label, display, or a user-defined password
269          * that has been configured to replace the original device password. */
270         WS_DEV_PASSWD_ID_DEFAULT = 0x0000,
271
272         /* User-specified indicates that the user has overridden the password
273          * with a manually selected value. */
274         WS_DEV_PASSWD_ID_USER_SPECIFIED = 0x0001,
275
276         /* Machine-specified indicates that the original PIN password has been
277          * overridden by a strong, machine-generated device password value. */
278         WS_DEV_PASSWD_ID_MACHINE_SPECIFIED = 0x0002,
279
280         /* The Rekey value indicates that the device's 256-bit rekeying
281          * password will be used. */
282         WS_DEV_PASSWD_ID_REKEY = 0x0003,
283
284         /* The PushButton value indicates that the PIN is the all-zero value
285          * reserved for the Push Button Configuration method. */
286         WS_DEV_PASSWD_ID_PUSH_BUTTON = 0x0004,
287
288         /* The Registrar-specified value indicates a PIN that has been
289          * obtained from the Registrar (via a display or other out-of-band
290          * method). This value may be further augmented with the optional
291          * "Identity" attribute in M1. */
292         WS_DEV_PASSWD_ID_REGISTRAR_SPECIFIED = 0x0005,  /* ENTER-PIN */
293
294         WS_DEV_PASSWD_ID_P2PS = 0x0008,
295 } ws_dev_passwd_id_e;
296
297 typedef enum {
298         WPS_ERROR_NONE,
299
300         WPS_ERROR_OOBINFO_READ_FAIL,
301         WPS_ERROR_DECRYPTION_FAIL,
302         WPS_ERROR_2G_NOT_SUPPORTED,
303         WPS_ERROR_5G_NOT_SUPPORTED,
304         WPS_ERROR_WEAK_SIGNAL,
305         WPS_ERROR_NET_AUTH_FAIL,
306         WPS_ERROR_NET_ASSOC_FAIL,
307         WPS_ERROR_NO_DHCP_RESPONSE,
308         WPS_ERROR_DHCP_CONFIG_FAIL,
309         WPS_ERROR_IP_CONFLICT,
310
311         WPS_ERROR_REGISTRAT_CONN_FAIL,
312         WPS_ERROR_PBC_SESSION_OVERLAP,
313         WPS_ERROR_ROGUE_ACTIVITY,
314         WPS_ERROR_DEVICE_BUSY,
315         WPS_ERROR_SETUP_LOCKED,
316         WPS_ERROR_MESSAGE_TIMEOUT,
317         WPS_ERROR_SESSION_TIMEOUT,
318         WPS_ERROR_PASSWORD_MISMATCH,
319 } ws_wps_error_e;
320
321 typedef enum {
322         WFD_SUBELM_ID_DEV_INFO,
323         WFD_SUBELM_ID_ASSOC_BSSID,
324         WFD_SUBELM_ID_AUDIO_FORMAT,
325         WFD_SUBELM_ID_VIDEO_FORMAT,
326         WFD_SUBELM_ID_3D_FORMAT,
327         WFD_SUBELM_ID_CONTENT_PROTECTION,
328
329         WFD_SUBELM_ID_CUPLED_SYNC_INFO,
330         WFD_SUBELM_ID_EXT_CAPAB,
331         WFD_SUBELM_ID_LOCAL_IP,
332         WFD_SUBELM_ID_SESSION_INFO,
333         WFD_SUBELM_ID_ALT_MAC,
334 } ws_wfd_subelm_id_e;
335
336 #define WFD_SUBELEM_LEN_DEV_INFO 6
337 #define WFD_SUBELM_LEN_ASSOC_BSSID 6
338 #define WFD_SUBELM_LEN_CUPLED_SYNC_INFO 7
339
340 typedef enum {
341         WFD_OEM_NETFLAG_CURRENT,
342         WFD_OEM_NETFLAG_DISABLED,
343         WFD_OEM_NETFLAG_TEMP_DISABLED,
344         WFD_OEM_NETFLAG_P2P_PERSISTENT,
345 } ws_netowrk_flag_e;
346
347 typedef struct {
348         int network_id;
349         char ssid[OEM_DEV_NAME_LEN+1];
350         unsigned char bssid[OEM_MACADDR_LEN];
351         char psk[OEM_PASS_PHRASE_LEN +1];
352         int proto;
353         int key_mgmt;
354         int pairwise;
355         int group;
356         int auth_alg;
357         int mode;
358         int p2p_client_num;
359         unsigned char p2p_client_list[OEM_MAX_PEER_NUM][OEM_MACADDR_LEN];
360         char persistent_path[OBJECT_PATH_MAX];
361         int total;
362 } ws_network_info_s;
363
364 typedef struct {
365         int initialized;        /* check whether plugin is initialized or not. block init function if initialized */
366         int activated;
367         int concurrent;
368
369         GDBusConnection *g_dbus;
370         char iface_path[150];
371         char group_iface_path[150];
372         unsigned char local_dev_addr[WS_MACADDR_LEN];
373         wfd_oem_event_cbs_s *callback;
374 } ws_dbus_plugin_data_s;
375
376 int ws_init(wfd_oem_event_cbs_s *event_cbs);
377 int ws_deinit(void);
378 int ws_activate(int concurrent);
379 int ws_deactivate(int concurrent);
380 int ws_start_scan(wfd_oem_scan_param_s *param);
381 int ws_restart_scan(int freq);
382 int ws_stop_scan(void);
383 int ws_get_visibility(int *visibility);
384 int ws_set_visibility(int visibility);
385 int ws_get_scan_result(GList **peers, int *peer_count);
386 int ws_get_peer_info(unsigned char *peer_addr, wfd_oem_device_s **peer);
387 int ws_prov_disc_req(unsigned char *peer_addr, wfd_oem_wps_mode_e wps_mode, int join);
388 int ws_connect(unsigned char *peer_addr, wfd_oem_conn_param_s *param);
389 int ws_disconnect(unsigned char *peer_addr, int is_iface_addr);
390 int ws_reject_connection(unsigned char *peer_addr);
391 int ws_cancel_connection(unsigned char *peer_addr);
392 int ws_get_connected_peers(GList **peers, int *peer_count);
393 int ws_get_pin(char *pin);
394 int ws_set_pin(char *pin);
395 int ws_generate_pin(char **pin);
396 int ws_get_supported_wps_mode(int *wps_mode);
397 int ws_create_group(wfd_oem_group_param_s *param);
398 int ws_destroy_group(const char *ifname);
399 int ws_invite(unsigned char *peer_addr, wfd_oem_invite_param_s *param);
400 int ws_wps_start(unsigned char *peer_addr, int wps_mode, const char *pin);
401 int ws_enrollee_start(unsigned char *peer_addr, int wps_mode, const char *pin);
402 int ws_wps_cancel(void);
403 int ws_get_dev_name(char *dev_name);
404 int ws_set_dev_name(char *dev_name);
405 int ws_get_dev_mac(char *dev_mac);
406 int ws_get_dev_type(int *pri_dev_type, int *sec_dev_type);
407 int ws_set_dev_type(int pri_dev_type, int sec_dev_type);
408 int ws_get_go_intent(int *go_intent);
409 int ws_set_go_intent(int go_intent);
410 int ws_set_country(char *ccode);
411
412 int ws_get_persistent_groups(wfd_oem_persistent_group_s **groups, int *group_count);
413 int ws_remove_persistent_group(char *ssid, unsigned char *bssid);
414 int ws_set_persistent_reconnect(unsigned char *bssid, int reconnect);
415
416 int ws_start_service_discovery(unsigned char *mac_addr, int service_type);
417 int ws_cancel_service_discovery(unsigned char *mac_addr, int service_type);
418
419 int ws_serv_add(wfd_oem_new_service_s *service);
420 int ws_serv_del(wfd_oem_new_service_s *service);
421
422 int ws_miracast_init(int enable);
423 int ws_set_display(wfd_oem_display_s *wifi_display);
424
425 int ws_refresh(void);
426 int ws_save_config(void);
427 int ws_set_operating_channel(int channel);
428 int ws_remove_all_network(void);
429 int ws_get_wpa_status(int *wpa_status);
430
431 int ws_advertise_service(wfd_oem_asp_service_s *service, int replace);
432 int ws_cancel_advertise_service(wfd_oem_asp_service_s *service);
433 int ws_seek_service(wfd_oem_asp_service_s *service);
434 int ws_cancel_seek_service(wfd_oem_asp_service_s *service);
435 int ws_asp_prov_disc_req(wfd_oem_asp_prov_s *asp_params);
436
437 int ws_add_vsie(wfd_oem_vsie_frames_e frame_id, const char* vsie);
438 int ws_get_vsie(wfd_oem_vsie_frames_e frame_id, char **vsie);
439 int ws_remove_vsie(wfd_oem_vsie_frames_e frame_id, const char *vsie);
440
441 #endif /* __WFD_PLUGIN_WPASUPPLICANT_H__ */