Prevent memory leak when initialization failure
[platform/core/connectivity/wifi-direct-manager.git] / oem / wifi-direct-oem.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 oem functions and structures.
22  *
23  * @file                wifi-direct-ome.h
24  * @author      Gibyoung Kim (lastkgb.kim@samsung.com)
25  * @version     0.7
26  */
27
28 #ifndef __WIFI_DIRECT_OEM_H__
29 #define __WIFI_DIRECT_OEM_H__
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #define SUPPL_PLUGIN_PATH "/usr/lib/wifi-direct-plugin-wpasupplicant.so"
36 #define SUPPL_PLUGIN_64BIT_PATH "/usr/lib64/wifi-direct-plugin-wpasupplicant.so"
37
38 #if defined TIZEN_ENABLE_PRD
39 #define SUPPL_PRD_PLUGIN_PATH "/usr/lib/wifi-direct-prd-plugin-wpasupplicant.so"
40 #define SUPPL_PRD_PLUGIN_64BIT_PATH "/usr/lib64/wifi-direct-prd-plugin-wpasupplicant.so"
41 #endif /* TIZEN_ENABLE_PRD */
42
43 #define COMMON_IFACE_NAME "wlan0"
44 #define P2P_IFACE_NAME "p2p0"
45 #define GROUP_IFACE_NAME "p2p0"
46 #define GROUP_IFACE_PREFIX "p2p"
47 #define PRIMARY_DEVICE_TYPE "\x00\x0a\x00\x50\xf2\x04\x00\x05"
48 #define DEFAULT_DEVICE_NAME "Tizen"
49 #define DEFAULT_GO_INTENT 7
50 #define DEFAULT_PERSISTENT_RECONNECT 1
51 #define DEFAULT_LISTEN_REG_CLASS 81
52 #define DEFAULT_LISTEN_CHANNEL 1
53 #define DEFAULT_OPER_REG_CLASS 81
54 #define DEFAULT_OPER_CHANNEL 1
55 #define DEFAULT_CONFIG_METHOD "display push_button keypad p2ps"
56 #define DEFAULT_NO_GROUP_IFACE 0
57 #define DEFAULT_CONNECTION_TIMEOUT 120
58
59 #define OEM_MACSTR_LEN 18
60 #define OEM_MACADDR_LEN 6
61 #define OEM_IPADDR_LEN 4
62 #define OEM_PINSTR_LEN 8
63 #define OEM_PASS_PHRASE_LEN 64
64 #define OEM_DEV_NAME_LEN 32
65 #define OEM_IFACE_NAME_LEN 16
66 #define OEM_SERVICE_TYPE_LEN 8
67 #define OEM_QUERY_ID_LEN 15
68 #define OEM_SERVICE_MAX_LEN 1024
69 #define OEM_CONFIG_METHOD_LEN 256
70 #define OEM_VSIE_MAX_LEN 1024
71
72 /* Referring to Wi-Fi Peer-to-Peer Services Technical Specification v1.1
73  * The default P2Ps PIN is 12345670. Any device decided to be GO will use
74  * that as device password
75  */
76 #define OEM_DEFAULT_P2PS_PIN "12345670"
77
78 #define OEM_MAX_PEER_NUM 8
79
80 #define P2P_MAX_CHANNELS 50
81
82 typedef enum {
83         WFD_OEM_SC_SUCCESS = 0,
84         WFD_OEM_SC_FAIL_INFO_CURRENTLY_UNAVAILABLE = 1,
85         WFD_OEM_SC_FAIL_INCOMPATIBLE_PARAMS = 2,
86         WFD_OEM_SC_FAIL_LIMIT_REACHED = 3,
87         WFD_OEM_SC_FAIL_INVALID_PARAMS = 4,
88         WFD_OEM_SC_FAIL_UNABLE_TO_ACCOMMODATE = 5,
89         WFD_OEM_SC_FAIL_PREV_PROTOCOL_ERROR = 6,
90         WFD_OEM_SC_FAIL_NO_COMMON_CHANNELS = 7,
91         WFD_OEM_SC_FAIL_UNKNOWN_GROUP = 8,
92         WFD_OEM_SC_FAIL_BOTH_GO_INTENT_15 = 9,
93         WFD_OEM_SC_FAIL_INCOMPATIBLE_PROV_METHOD = 10,
94         WFD_OEM_SC_FAIL_REJECTED_BY_USER = 11,
95         WFD_OEM_SC_SUCCESS_ACCEPTED_BY_USER = 12,
96 } wfd_oem_status_code_e;
97
98 typedef enum {
99         WFD_OEM_WPA_STATE_DISCONNECTED,
100         WFD_OEM_WPA_STATE_INTERFACE_DISABLED,
101         WFD_OEM_WPA_STATE_INACTIVE,
102         WFD_OEM_WPA_STATE_SCANNING,
103         WFD_OEM_WPA_STATE_AUTHENTICATING,
104         WFD_OEM_WPA_STATE_ASSOCIATING,
105         WFD_OEM_WPA_STATE_ASSOCIATED,
106         WFD_OEM_WPA_STATE_4WAY_HANDSHAKE,
107         WFD_OEM_WPA_STATE_GROUP_HANDSHAKE,
108         WFD_OEM_WPA_STATE_COMPLETED,
109         WFD_OEM_WPA_STATE_MAX,
110 } ws_wpa_state_type_e;
111
112 typedef enum {
113         WFD_OEM_ASP_WPS_TYPE_NONE = 0x00,  /**< No WPS type */
114         WFD_OEM_ASP_WPS_TYPE_DEFAULT = 0x00,  /**< Default WPS type both P2PS and PIN */
115         WFD_OEM_ASP_WPS_TYPE_PIN_BOTH = 0x02,  /**< WPS type PIN code both display and keypad*/
116         WFD_OEM_ASP_WPS_TYPE_PIN_DISPLAY = 0x03,  /**< WPS type display PIN code only*/
117         WFD_OEM_ASP_WPS_TYPE_PIN_KEYPAD = 0x04,  /**< WPS type keypad to input the PIN only*/
118 } asp_wps_type_e;
119
120 typedef enum {
121         WFD_OEM_ASP_SESSION_ROLE_NONE = 0x00,  /**< Session network role none */
122         WFD_OEM_ASP_SESSION_ROLE_NEW = 0x01,  /**< Session network role new */
123         WFD_OEM_ASP_SESSION_ROLE_CLIENT = 0x02,  /**< Session network role client */
124         WFD_OEM_ASP_SESSION_ROLE_GO = 0x04,  /**< Session network role GO */
125 } wfd_oem_asp_network_role_e;
126
127 typedef enum {
128         WFD_OEM_EVENT_NONE,
129         WFD_OEM_EVENT_DEACTIVATED,
130         WFD_OEM_EVENT_PEER_FOUND,
131         WFD_OEM_EVENT_PEER_DISAPPEARED,
132         WFD_OEM_EVENT_DISCOVERY_FINISHED,
133
134         WFD_OEM_EVENT_PROV_DISC_REQ,    /* 5 */
135         WFD_OEM_EVENT_PROV_DISC_RESP,
136         WFD_OEM_EVENT_PROV_DISC_FAIL,
137
138         WFD_OEM_EVENT_GO_NEG_REQ,
139         WFD_OEM_EVENT_GO_NEG_FAIL,
140         WFD_OEM_EVENT_GO_NEG_DONE,      /* 10 */
141         WFD_OEM_EVENT_WPS_FAIL,
142         WFD_OEM_EVENT_WPS_DONE,
143         WFD_OEM_EVENT_KEY_NEG_FAIL,
144         WFD_OEM_EVENT_KEY_NEG_DONE,
145
146         WFD_OEM_EVENT_CONN_FAIL,        /* 15 */
147         WFD_OEM_EVENT_CONN_DONE,
148
149         WFD_OEM_EVENT_GROUP_CREATED,
150         WFD_OEM_EVENT_GROUP_DESTROYED,
151
152         WFD_OEM_EVENT_INVITATION_REQ,
153         WFD_OEM_EVENT_INVITATION_RES,   /* 20 */
154         WFD_OEM_EVENT_STA_CONNECTED,
155         WFD_OEM_EVENT_STA_DISCONNECTED,
156
157         WFD_OEM_EVENT_TERMINATING,      /* 23 */
158
159         WFD_OEM_EVENT_SERV_DISC_RESP,
160         WFD_OEM_EVENT_SERV_DISC_STARTED,
161
162         WFD_OEM_EVENT_GROUP_FORMATION_FAILURE,
163         WFD_OEM_EVENT_INVITATION_ACCEPTED,
164
165         WFD_OEM_EVENT_ASP_SERV_RESP,
166         WFD_OEM_EVENT_ASP_PROV_START,
167         WFD_OEM_EVENT_ASP_PROV_DONE,
168
169         WFD_OEM_EVENT_MAX,
170 } wfd_oem_event_e;
171
172 /**
173  * This enumeration is used in frame id value in vsie method calls
174  */
175 typedef enum {
176         WFD_OEM_VSIE_FRAME_P2P_PROBE_REQ = 0,
177         WFD_OEM_VSIE_FRAME_P2P_PROBE_RESP = 1,
178         WFD_OEM_VSIE_FRAME_P2P_GO_PROBE_RESP = 2,
179         WFD_OEM_VSIE_FRAME_P2P_GO_BEACON = 3,
180         WFD_OEM_VSIE_FRAME_P2P_PD_REQ = 4,
181         WFD_OEM_VSIE_FRAME_P2P_PD_RESP = 5,
182         WFD_OEM_VSIE_FRAME_P2P_GO_NEG_REQ = 6,
183         WFD_OEM_VSIE_FRAME_P2P_GO_NEG_RESP = 7,
184         WFD_OEM_VSIE_FRAME_P2P_GO_NEG_CONF = 8,
185         WFD_OEM_VSIE_FRAME_P2P_INV_REQ = 9,
186         WFD_OEM_VSIE_FRAME_P2P_INV_RESP = 10,
187         WFD_OEM_VSIE_FRAME_P2P_ASSOC_REQ = 11,
188         WFD_OEM_VSIE_FRAME_P2P_ASSOC_RESP = 12,
189         WFD_OEM_VSIE_FRAME_ASSOC_REQ = 13,
190         WFD_OEM_VSIE_FRAME_MAX
191 } wfd_oem_vsie_frames_e;
192
193 typedef enum {
194         WFD_OEM_DISPLAY_TYPE_SOURCE,
195         WFD_OEM_DISPLAY_TYPE_PRISINK,
196         WFD_OEM_DISPLAY_TYPE_SECSINK,
197         WFD_OEM_DISPLAY_TYPE_DUAL,
198 } wfd_oem_display_type_e;
199
200 typedef struct {
201         char ifname[OEM_IFACE_NAME_LEN+1];
202         char p2p_ifname[OEM_IFACE_NAME_LEN+1];
203         char group_ifname[OEM_IFACE_NAME_LEN+1];
204         char device_name[OEM_DEV_NAME_LEN+1];
205         int pri_dev_type;
206         int sec_dev_type;
207         int go_intent;
208         gboolean persistent_reconnect;
209         int listen_reg_class;
210         int listen_channel;
211         int operating_reg_class;
212         int operating_channel;
213         char config_methods[OEM_CONFIG_METHOD_LEN+1];
214         gboolean no_group_iface;
215         int group_operating_freq;
216         int connection_timeout;
217 } wfd_oem_config_s;
218
219 typedef struct {
220         int type;
221         int availability;
222         int wsd_support;
223         int tdls_support;
224         int hdcp_support;
225         int sync_support;
226         int port;
227         int max_tput;
228 } wfd_oem_display_s;
229
230 typedef struct {
231         unsigned int adv_id;
232         unsigned int config_method;
233         long long unsigned search_id;
234         unsigned char service_type_length;
235         char *service_type;
236         unsigned char instance_name_length;
237         char *instance_name;
238 } wfd_oem_advertise_service_s;
239
240 typedef struct {
241         int age;
242         char dev_name[OEM_DEV_NAME_LEN+1];
243         unsigned char dev_addr[OEM_MACADDR_LEN];
244         unsigned char intf_addr[OEM_MACADDR_LEN];
245         unsigned char go_dev_addr[OEM_MACADDR_LEN];
246         int channel;
247         int dev_role;
248         int config_methods;
249         int pri_dev_type;
250         int sec_dev_type;
251         int dev_flags;
252         int group_flags;
253         int wps_mode;
254         wfd_oem_display_s display;
255         int rssi;
256         char *vsie;
257 } wfd_oem_device_s;
258
259 typedef struct {
260         unsigned char p2p_dev_addr[OEM_MACADDR_LEN];
261         unsigned char p2p_intf_addr[OEM_MACADDR_LEN];
262         char name[OEM_DEV_NAME_LEN + 1];
263         int pri_dev_type;
264         int sec_dev_type;
265         int config_methods;
266         int dev_flags;
267         int group_flags;
268         int dev_role;
269         int device_go_intent;
270         wfd_oem_display_s display;
271         unsigned char p2p_go_addr[OEM_MACADDR_LEN];
272         int has_asp_services;
273         int has_asp2_services;
274         int rssi;
275         char *vsie;
276 } wfd_oem_dev_data_s;
277
278 typedef struct {
279         char ssid[OEM_DEV_NAME_LEN+1];
280         unsigned char peer_device_addr[OEM_MACADDR_LEN];
281         unsigned char peer_intf_addr[OEM_MACADDR_LEN];
282         int persistent_group;
283         int wps_mode;
284         int status;
285         int error;
286 } wfd_oem_conn_data_s;
287
288 typedef struct {
289         unsigned char sa[OEM_MACADDR_LEN];
290         unsigned char go_dev_addr[OEM_MACADDR_LEN];
291         unsigned char bssid[OEM_MACADDR_LEN];
292         int persistent_id;
293         int oper_freq;
294         int listen;
295         int status;
296 } wfd_oem_invite_data_s;
297
298 typedef struct {
299         char ssid[OEM_DEV_NAME_LEN+1];
300         int freq;
301         int is_persistent;
302         char pass[OEM_PASS_PHRASE_LEN+1];
303         unsigned char go_dev_addr[OEM_MACADDR_LEN];
304         unsigned char ip_addr[OEM_IPADDR_LEN];
305         unsigned char ip_addr_mask[OEM_IPADDR_LEN];
306         unsigned char ip_addr_go[OEM_IPADDR_LEN];
307 } wfd_oem_group_data_s;
308
309 typedef enum {
310         WFD_OEM_SERV_STATUS_SUCCESS,
311         WFD_OEM_SERV_STATUS_FAIL,
312 } wfd_oem_serv_status_e;
313
314 typedef enum {
315         WFD_OEM_SERV_TYPE_ALL,
316         WFD_OEM_SERV_TYPE_BTADDR,
317 } wfd_oem_serv_type_e;
318
319 typedef struct {
320         int status;
321         int type;
322         unsigned char data[OEM_MACADDR_LEN];
323         unsigned char value[20];
324 } wfd_oem_service_data_s;
325
326 typedef struct {
327         int event_id;
328         unsigned char dev_addr[OEM_MACADDR_LEN];        /* device address */
329         unsigned char intf_addr[OEM_MACADDR_LEN];
330         int wps_mode;
331         char wps_pin[OEM_PINSTR_LEN+1]; /* just for DISPLAY */
332         char ifname[OEM_IFACE_NAME_LEN+1];
333         int dev_role;
334         unsigned char ip_addr_peer[OEM_IPADDR_LEN];
335         int edata_type;
336         void *edata;
337         void *asp_services;
338         void *asp2_services;
339 } wfd_oem_event_s;
340
341 typedef enum {
342         WFD_OEM_EDATA_TYPE_NONE,
343         WFD_OEM_EDATA_TYPE_DEVICE,
344         WFD_OEM_EDATA_TYPE_CONN,
345         WFD_OEM_EDATA_TYPE_INVITE,
346         WFD_OEM_EDATA_TYPE_GROUP,
347         WFD_OEM_EDATA_TYPE_SERVICE,
348         WFD_OEM_EDATA_TYPE_NEW_SERVICE,
349         WFD_OEM_EDATA_TYPE_ASP_SERVICE,
350         WFD_OEM_EDATA_TYPE_ASP_PROV,
351 } ws_event_type_e;
352
353 typedef enum {
354         WFD_OEM_SCAN_MODE_ACTIVE,
355         WFD_OEM_SCAN_MODE_PASSIVE,
356 } wfd_oem_scan_mode_e;
357
358 typedef enum {
359         WFD_OEM_SCAN_TYPE_FULL,
360         WFD_OEM_SCAN_TYPE_SOCIAL,
361         WFD_OEM_SCAN_TYPE_SPECIFIC,
362         WFD_OEM_SCAN_TYPE_CHANNEL1,
363         WFD_OEM_SCAN_TYPE_CHANNEL6,
364         WFD_OEM_SCAN_TYPE_CHANNEL11,
365         WFD_OEM_SCAN_TYPE_GO_FREQ,
366 } wfd_oem_scan_type_e;
367
368 typedef enum {
369         WFD_OEM_WPS_MODE_NONE,
370         WFD_OEM_WPS_MODE_PBC = 0x1,
371         WFD_OEM_WPS_MODE_DISPLAY = 0x2,
372         WFD_OEM_WPS_MODE_KEYPAD = 0x4,
373         WFD_OEM_WPS_MODE_P2PS = 0x8,
374 } wfd_oem_wps_mode_e;
375
376 #define WFD_OEM_GROUP_FLAG_GROUP_OWNER 0x1
377 #define WFD_OEM_GROUP_FLAG_PERSISTENT_GROUP 0x2
378
379 typedef enum {
380         WFD_OEM_CONN_TYPE_NONE,
381         WFD_OEM_CONN_TYPE_JOIN,
382         WFD_OEM_CONN_TYPE_AUTH,
383         WFD_OEM_CONN_TYPE_PERSISTENT = 0x4,
384 } wfd_oem_conn_flag_e;
385
386 typedef enum {
387         WFD_OEM_DEV_ROLE_NONE,
388         WFD_OEM_DEV_ROLE_GC,
389         WFD_OEM_DEV_ROLE_GO,
390 } wfd_oem_dev_role_e;
391
392 typedef struct {
393         int scan_mode;
394         int scan_time;
395         int scan_type;
396         int freq;
397         int refresh;
398         char *seek;
399 } wfd_oem_scan_param_s;
400
401 typedef struct {
402         int wps_mode;
403         int conn_flags; /* join, auth, persistent */
404         int go_intent;
405         int freq;
406         char wps_pin[OEM_PINSTR_LEN+1];
407 } wfd_oem_conn_param_s;
408
409 typedef struct {
410         int persistent;
411         int persistent_group_id;
412         int freq;
413         char passphrase[OEM_PASS_PHRASE_LEN + 1];
414         char ssid[OEM_DEV_NAME_LEN + 1];
415 } wfd_oem_group_param_s;
416
417 typedef struct {
418         int net_id;
419         char *ifname;
420         unsigned char go_dev_addr[OEM_MACADDR_LEN];
421 } wfd_oem_invite_param_s;
422
423 typedef enum {
424         WFD_OEM_CONFIG_ATTR_STR_DEVICE_NAME,
425         WFD_OEM_CONFIG_ATTR_STR_SSID_POSTFIX,
426         WFD_OEM_CONFIG_ATTR_STR_COUNTRY,
427         WFD_OEM_CONFIG_ATTR_NUM_GO_INTENT,
428         WFD_OEM_CONFIG_ATTR_NUM_LISTEN_FREQ,
429         WFD_OEM_CONFIG_ATTR_NUM_OPER_FREQ,
430         WFD_OEM_CONFIG_ATTR_NUM_PREF_FREQ,
431         WFD_OEM_CONFIG_ATTR_NUM_PERSIST_RECONN,
432         WFD_OEM_CONFIG_ATTR_NUM_WIFI_DISPLAY,
433         WFD_OEM_CONFIG_ATTR_NUM_P2P_DISABLED,
434         WFD_OEM_CONFIG_ATTR_NUM_MAX_STA,
435         WFD_OEM_CONFIG_ATTR_LIMIT = WFD_OEM_CONFIG_ATTR_NUM_MAX_STA,
436 } wfd_oem_conf_attr_e;
437
438 typedef enum {
439         WFD_OEM_SERVICE_TYPE_ALL,
440         WFD_OEM_SERVICE_TYPE_BONJOUR,
441         WFD_OEM_SERVICE_TYPE_UPNP,
442         WFD_OEM_SERVICE_TYPE_WS_DISCOVERY,
443         WFD_OEM_SERVICE_TYPE_WIFI_DISPLAY,
444         WFD_OEM_SERVICE_TYPE_VENDOR = 0xff,
445 } wfd_oem_service_type_e;
446
447 typedef enum {
448         WFD_OEM_BONJOUR_RDATA_PTR = 0x0c,
449         WFD_OEM_BONJOUR_RDATA_TXT = 0x10,
450 } wfd_oem_bonjour_rdata_type_e;
451
452 typedef struct {
453         /** Device address for which service discovery is requested */
454         char dev_addr[OEM_MACSTR_LEN+1];
455
456         /** service type requested */
457         char service_type[OEM_SERVICE_TYPE_LEN+1];
458
459         /** query identifier returned by wpa_supplicant for each service discovery request */
460         char query_id[OEM_QUERY_ID_LEN+1];
461 } wfd_oem_service_s;
462
463 typedef struct {
464         int protocol;
465         int trans_id;
466         int status;
467         char *str_ptr;
468         union {
469                 struct {
470                         char *version;
471                         char *service;
472                 } upnp;
473                 struct {
474                         char *query;
475                         char *rdata;
476                         wfd_oem_bonjour_rdata_type_e rdata_type;
477                 } bonjour;
478                 struct {
479                         char *data1;
480                         char *data2;
481                 } vendor;
482         } data;
483 } wfd_oem_new_service_s;
484
485 #define WFD_OEM_STR_PROTO_WPA "WPA"
486 #define WFD_OEM_STR_PROTO_RSN "RSN"
487 #define WFD_OEM_STR_KEY_MGMT_IEEE8021X "WPA-EAP"
488 #define WFD_OEM_STR_KEY_MGMT_PSK "WPA-PSK"
489 #define WFD_OEM_STR_KEY_MGMT_NONE "WPA-NONE"
490 #define WFD_OEM_STR_CIPHER_NONE "NONE"
491 #define WFD_OEM_STR_CIPHER_WEP40 "WEP40"
492 #define WFD_OEM_STR_CIPHER_WEP104 "WEP104"
493 #define WFD_OEM_STR_CIPHER_TKIP "TKIP"
494 #define WFD_OEM_STR_CIPHER_CCMP "CCMP"
495 #define WFD_OEM_STR_AUTH_ALG_OPEN "OPEN"
496 #define WFD_OEM_STR_MODE_GC "0"
497 #define WFD_OEM_STR_MODE_GO "3"
498
499 typedef enum {
500         WFD_OEM_PROTO_WPA = 0x01, /* WPA */
501         WFD_OEM_PROTO_RSN = 0x02, /* RSN */
502 } wfd_oem_proto_e;
503
504 typedef enum {
505         WFD_OEM_KEY_MGMT_IEEE8021X = 0x01,      /* WPA-EAP */
506         WFD_OEM_KEY_MGMT_PSK = 0x02,    /* WPA-PSK */
507         WFD_OEM_KEY_MGMT_NONE = 0x04, /* WPA-NONE */
508 } wfd_oem_key_mgmt_e;
509
510 typedef enum {
511         WFD_OEM_CIPHER_NONE = 0x01, /* NONE */
512         WFD_OEM_CIPHER_WEP40 = 0x02, /* WEP40 */
513         WFD_OEM_CIPHER_WEP104 = 0x04, /* WEP104 */
514         WFD_OEM_CIPHER_TKIP = 0x08, /* TKIP */
515         WFD_OEM_CIPHER_CCMP = 0x10, /* CCMP */
516 } wfd_oem_cipher_e;
517
518 typedef enum {
519         WFD_OEM_AUTH_ALG_OPEN = 0x01, /* OPEN */
520 } wfd_oem_auth_alg_e;
521
522 typedef enum {
523         WFD_OEM_PERSISTENT_MODE_GC = 0x1,
524         WFD_OEM_PERSISTENT_MODE_GO = 0x2,
525 } wfd_oem_persistent_mode_e;
526
527 typedef enum {
528         WFD_OEM_TYPE_ADVERTISE,
529         WFD_OEM_TYPE_SEEK,
530         WFD_OEM_TYPE_MAX,
531 } wfd_oem_asp_service_type_e;
532
533 typedef struct {
534         wfd_oem_asp_service_type_e type;
535         unsigned int adv_id;
536         long long unsigned asp_search_id;
537         long long unsigned search_id;
538         int auto_accept;
539         int discovery_tech;
540         unsigned char preferred_connection;
541
542         unsigned char status;
543         unsigned char role;
544         unsigned int config_method;
545         unsigned char tran_id;
546
547         char *instance_name;
548         char *service_name;
549         char *service_type;
550         char *service_info;
551         char *rsp_info;
552 } wfd_oem_asp_service_s;
553
554 typedef struct {
555         unsigned char session_mac[OEM_MACADDR_LEN];
556         unsigned int session_id;
557         unsigned int adv_id;
558         int network_config;
559         int network_role;
560         int port;
561         int persist;
562         int persistent_group_id;
563         char *session_information;
564         int proto;
565         int status;
566         int deferring;
567         unsigned char service_mac[OEM_MACADDR_LEN];
568         unsigned char group_mac[OEM_MACADDR_LEN];
569         char wps_pin[OEM_PINSTR_LEN+1];
570         unsigned char ip_addr[OEM_IPADDR_LEN];
571 } wfd_oem_asp_prov_s;
572
573 typedef struct {
574         int network_id;
575         char ssid[OEM_DEV_NAME_LEN + 1];
576         unsigned char go_mac_address[OEM_MACADDR_LEN];
577         char psk[OEM_PASS_PHRASE_LEN +1];
578         int proto;
579         int key_mgmt;
580         int pairwise;
581         int group;
582         int auth_alg;
583         int mode;
584         int p2p_client_num;
585         unsigned char p2p_client_list[OEM_MAX_PEER_NUM][OEM_MACADDR_LEN];
586 } wfd_oem_persistent_group_s;
587
588 typedef struct {
589         int channels[P2P_MAX_CHANNELS];
590         int count;
591 } wfd_oem_supported_channels_s;
592
593 typedef struct {
594         void (*deactivated_cb) (wfd_oem_event_s *event);
595         void (*peer_found_cb) (wfd_oem_event_s *event);
596         void (*peer_disappeared_cb) (wfd_oem_event_s *event);
597         void (*discovery_finished_cb) (wfd_oem_event_s *event);
598
599         void (*prov_disc_req_cb) (wfd_oem_event_s *event);
600         void (*prov_disc_resp_cb) (wfd_oem_event_s *event);
601         void (*prov_disc_fail_cb) (wfd_oem_event_s *event);
602
603         void (*go_neg_req_cb) (wfd_oem_event_s *event);
604         void (*go_neg_fail_cb) (wfd_oem_event_s *event);
605         void (*go_neg_done_cb) (wfd_oem_event_s *event);
606
607         void (*wps_fail_cb) (wfd_oem_event_s *event);
608         void (*wps_done_cb) (wfd_oem_event_s *event);
609         void (*key_neg_fail_cb) (wfd_oem_event_s *event);
610         void (*key_neg_done_cb) (wfd_oem_event_s *event);
611
612         void (*conn_fail_cb) (wfd_oem_event_s *event);
613         void (*conn_done_cb) (wfd_oem_event_s *event);
614
615         void (*group_created_cb) (wfd_oem_event_s *event);
616         void (*group_destroyed_cb) (wfd_oem_event_s *event);
617
618         void (*invitation_req_cb) (wfd_oem_event_s *event);
619         void (*invitation_resp_cb) (wfd_oem_event_s *event);
620         void (*sta_connected_cb) (wfd_oem_event_s *event);
621         void (*sta_disconnected_cb) (wfd_oem_event_s *event);
622
623         void (*terminating_cb) (wfd_oem_event_s *event);
624
625         void (*serv_disc_resp_cb) (wfd_oem_event_s *event);
626         void (*serv_disc_started_cb) (wfd_oem_event_s *event);
627
628         void (*group_formation_failure_cb) (wfd_oem_event_s *event);
629         void (*invitation_accepted_cb) (wfd_oem_event_s *event);
630
631         void (*asp_serv_resp_cb) (wfd_oem_event_s *event);
632         void (*asp_prov_start_cb) (wfd_oem_event_s *event);
633         void (*asp_prov_done_cb) (wfd_oem_event_s *event);
634
635         void *extra_data;
636 } wfd_oem_event_cbs_s;
637
638 typedef struct {
639         int (*configure) (wfd_oem_config_s *conf);
640         int (*init) (wfd_oem_event_cbs_s *event_cbs);
641         int (*deinit) (void);
642         int (*activate) (int concurrent);
643         int (*deactivate) (int concurrent);
644
645         int (*start_scan) (wfd_oem_scan_param_s *param);
646         int (*stop_scan) (void);
647         int (*get_visibility) (int *visibility);
648         int (*set_visibility) (int visibility);
649         int (*get_scan_result) (GList **peers, int *peer_count);
650         int (*get_peer_info) (unsigned char *peer_addr, wfd_oem_device_s **peer);
651         int (*prov_disc_req) (unsigned char *peer_addr, wfd_oem_wps_mode_e wps_mode, int join);
652         int (*connect) (unsigned char *peer_addr, wfd_oem_conn_param_s *param);
653         int (*disconnect) (unsigned char *peer_addr, int is_iface_addr);
654         int (*reject_connection) (unsigned char *peer_addr);
655         int (*cancel_connection) (unsigned char *peer_addr);
656         int (*get_connected_peers) (GList **peers, int *peer_count);
657         int (*wps_start) (unsigned char *peer_addr, int wps_mode, const char *pin);
658         int (*enrollee_start) (unsigned char *peer_addr, int wps_mode, const char *pin);
659         int (*wps_cancel) (void);
660         int (*get_pin) (char *pin);
661         int (*set_pin) (char *pin);
662         int (*generate_pin) (char **pin);
663         int (*get_supported_wps_mode) (int *wps_mode);
664         int (*create_group) (wfd_oem_group_param_s *param);
665         int (*destroy_group) (const char *ifname);
666         int (*invite) (unsigned char *peer_addr, wfd_oem_invite_param_s *param);
667
668         int (*get_dev_name) (char *dev_name);
669         int (*set_dev_name) (char *dev_name);
670         int (*get_dev_mac) (char *dev_mac);
671         int (*get_dev_type) (int *pri_dev_type, int *sec_dev_type);
672         int (*set_dev_type) (int pri_dev_type, int sec_dev_type);
673         int (*get_go_intent) (int *go_intent);
674         int (*set_go_intent) (int go_intent);
675         int (*set_country) (char *ccode);
676
677         int (*get_persistent_groups) (wfd_oem_persistent_group_s **groups, int *group_count);
678         int (*remove_persistent_group) (char *ssid, unsigned char *bssid);
679         int (*set_persistent_reconnect) (unsigned char *bssid, int reconnect);
680
681         int (*start_service_discovery) (unsigned char mac_addr[6], int service_type);
682         int (*cancel_service_discovery) (unsigned char mac_addr[6], int service_type);
683
684         int (*serv_add) (wfd_oem_new_service_s *service);
685         int (*serv_del) (wfd_oem_new_service_s *service);
686         int (*serv_disc_start) (wfd_oem_new_service_s *service);
687         int (*serv_disc_stop) (int handle);
688
689         int (*miracast_init) (int enable);
690         int (*set_display) (wfd_oem_display_s *wifi_display);
691
692         int (*refresh) (void);
693         int (*save_config) (void);
694         int (*set_operating_channel)(int channel);
695         int (*remove_all_network)(void);
696         int (*get_wpa_status)(int *wpa_status);
697
698         int (*advertise_service)(wfd_oem_asp_service_s *service, int replace);
699         int (*cancel_advertise_service)(wfd_oem_asp_service_s *service);
700         int (*seek_service)(wfd_oem_asp_service_s *service);
701         int (*cancel_seek_service)(wfd_oem_asp_service_s *service);
702         int (*asp_prov_disc_req)(wfd_oem_asp_prov_s *params);
703
704         int (*set_eapol_ip_config)(int enable);
705
706         int (*add_vsie)(wfd_oem_vsie_frames_e frame_id, const char* vsie);
707         int (*get_vsie)(wfd_oem_vsie_frames_e frame_id, char **vsie);
708         int (*remove_vsie)(wfd_oem_vsie_frames_e frame_id, const char *vsie);
709         int (*set_supported_wps_mode) (int wps_mode);
710         int (*remove_persistent_device) (unsigned char *peer_mac_addr);
711         int (*remove_all_persistent_device) (void);
712
713         int (*get_supported_channels) (wfd_oem_supported_channels_s *data);
714
715         void *extra_data;
716 } wfd_oem_ops_s;
717
718 int wfd_oem_configure(wfd_oem_ops_s *ops, wfd_oem_config_s *conf);
719 int wfd_oem_init(wfd_oem_ops_s *ops);
720 int wfd_oem_destroy(wfd_oem_ops_s *ops);
721 int wfd_oem_activate(wfd_oem_ops_s *ops, int concurrent);
722 int wfd_oem_deactivate(wfd_oem_ops_s *ops, int concurrent);
723
724 int wfd_oem_start_scan(wfd_oem_ops_s *ops, wfd_oem_scan_param_s *param);
725 int wfd_oem_stop_scan(wfd_oem_ops_s *ops);
726 int wfd_oem_get_visibility(wfd_oem_ops_s *ops, int *visibility);
727 int wfd_oem_set_visibility(wfd_oem_ops_s *ops, int visibility);
728 int wfd_oem_get_scan_result(wfd_oem_ops_s *ops, GList **peers, int *peer_count);
729 int wfd_oem_get_peer_info(wfd_oem_ops_s *ops, unsigned char *peer_addr, wfd_oem_device_s **peer);
730 int wfd_oem_prov_disc_req(wfd_oem_ops_s *ops, unsigned char *peer_addr, wfd_oem_wps_mode_e wps_mode, int join);
731 int wfd_oem_connect(wfd_oem_ops_s *ops, unsigned char *peer_addr, wfd_oem_conn_param_s *param);
732 int wfd_oem_disconnect(wfd_oem_ops_s *ops, unsigned char *peer_addr, int is_iface_addr);
733 int wfd_oem_reject_connection(wfd_oem_ops_s *ops, unsigned char *peer_addr);
734 int wfd_oem_cancel_connection(wfd_oem_ops_s *ops, unsigned char *peer_addr);
735 int wfd_oem_get_connected_peers(wfd_oem_ops_s *ops, GList **peers, int *peer_count);
736 int wfd_oem_wps_start(wfd_oem_ops_s *ops, unsigned char *peer_addr, int wps_mode, const char *pin);
737 int wfd_oem_enrollee_start(wfd_oem_ops_s *ops, unsigned char *peer_addr, int wps_mode, const char *pin);
738 int wfd_oem_wps_cancel(wfd_oem_ops_s *ops);
739 int wfd_oem_get_pin(wfd_oem_ops_s *ops, char *pin);
740 int wfd_oem_set_pin(wfd_oem_ops_s *ops, char *pin);
741 int wfd_oem_generate_pin(wfd_oem_ops_s *ops, char **pin);
742 int wfd_oem_get_supported_wps_mode(wfd_oem_ops_s *ops, int *wps_mode);
743 int wfd_oem_create_group(wfd_oem_ops_s *ops, wfd_oem_group_param_s *param);
744 int wfd_oem_destroy_group(wfd_oem_ops_s *ops, const char *ifname);
745 int wfd_oem_invite(wfd_oem_ops_s *ops, unsigned char *peer_addr, wfd_oem_invite_param_s *param);
746
747 int wfd_oem_get_dev_name(wfd_oem_ops_s *ops, char *dev_name);
748 int wfd_oem_set_dev_name(wfd_oem_ops_s *ops, char *dev_name);
749 int wfd_oem_get_dev_mac(wfd_oem_ops_s *ops, char *dev_mac);
750 int wfd_oem_get_dev_type(wfd_oem_ops_s *ops, int *pri_dev_type, int *sec_dev_type);
751 int wfd_oem_set_dev_type(wfd_oem_ops_s *ops, int priv_dev_type, int sec_dev_type);
752 int wfd_oem_get_go_intent(wfd_oem_ops_s *ops, int *go_intent);
753 int wfd_oem_set_go_intent(wfd_oem_ops_s *ops, int go_intent);
754 int wfd_oem_set_country(wfd_oem_ops_s *ops, char *ccode);
755
756 int wfd_oem_get_persistent_groups(wfd_oem_ops_s *ops, wfd_oem_persistent_group_s **groups, int *group_count);
757 int wfd_oem_remove_persistent_group(wfd_oem_ops_s *ops, char *ssid, unsigned char *bssid);
758 int wfd_oem_set_persistent_reconnect(wfd_oem_ops_s *ops, unsigned char *bssid, int reconnect);
759
760 int wfd_oem_start_service_discovery(wfd_oem_ops_s *ops, unsigned char *peer_addr, int service_type);
761 int wfd_oem_cancel_service_discovery(wfd_oem_ops_s *ops, unsigned char *peer_addr, int service_type);
762
763 int wfd_oem_serv_add(wfd_oem_ops_s *ops, wfd_oem_new_service_s *service);
764 int wfd_oem_serv_del(wfd_oem_ops_s *ops, wfd_oem_new_service_s *service);
765 int wfd_oem_serv_disc_start(wfd_oem_ops_s *ops, wfd_oem_new_service_s *service);
766 int wfd_oem_serv_disc_stop(wfd_oem_ops_s *ops, int handle);
767
768 int wfd_oem_miracast_init(wfd_oem_ops_s *ops, int enable);
769 int wfd_oem_set_display(wfd_oem_ops_s *ops, wfd_oem_display_s *wifi_display);
770
771 int wfd_oem_refresh(wfd_oem_ops_s *ops);
772
773 int wfd_oem_advertise_service(wfd_oem_ops_s *ops, wfd_oem_asp_service_s *service, int replace);
774 int wfd_oem_cancel_advertise_service(wfd_oem_ops_s *ops, wfd_oem_asp_service_s *service);
775 int wfd_oem_seek_service(wfd_oem_ops_s *ops, wfd_oem_asp_service_s *service);
776 int wfd_oem_cancel_seek_service(wfd_oem_ops_s *ops, wfd_oem_asp_service_s *service);
777 int wfd_oem_asp_prov_disc_req(wfd_oem_ops_s *ops, wfd_oem_asp_prov_s *params);
778
779 int wfd_oem_set_eapol_ip_config(wfd_oem_ops_s *ops, int enable);
780
781 int wfd_oem_add_vsie(wfd_oem_ops_s *ops, wfd_oem_vsie_frames_e frame_id,
782                      const char* vsie);
783 int wfd_oem_get_vsie(wfd_oem_ops_s *ops, wfd_oem_vsie_frames_e frame_id,
784                      char **vsie);
785 int wfd_oem_remove_vsie(wfd_oem_ops_s *ops, wfd_oem_vsie_frames_e frame_id,
786                         const char *vsie);
787 int wfd_oem_get_supported_wps_mode(wfd_oem_ops_s *ops, int *wps_mode);
788 int wfd_oem_set_supported_wps_mode(wfd_oem_ops_s *ops, int wps_mode);
789 int wfd_oem_remove_persistent_device(wfd_oem_ops_s *ops, unsigned char *peer_mac_address);
790 int wfd_oem_remove_all_persistent_device(wfd_oem_ops_s *ops);
791
792 int wfd_oem_get_supported_channels(wfd_oem_ops_s *ops, wfd_oem_supported_channels_s *data);
793
794 #if defined TIZEN_ENABLE_PRD
795 typedef struct {
796         void (*prd_example_cb) (wfd_oem_event_s *event);
797 } wfd_oem_prd_event_cbs_s;
798
799 typedef struct {
800         int (*prd_init) (wfd_oem_event_cbs_s *event_cbs);
801 } wfd_oem_prd_ops_s;
802
803 int wfd_oem_prd_init(wfd_oem_ops_s *ops);
804 #endif /* TIZEN_ENABLE_PRD */
805
806 #ifdef __cplusplus
807 }
808 #endif
809
810 #endif /* __WIFI_DIRECT_OEM_H__ */