1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef OHOS_C_P2P_CONFIG_H
17#define OHOS_C_P2P_CONFIG_H
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#ifndef COMMON_MAC_LEN
24#define COMMON_MAC_LEN 6
25#endif
26
27#define PASSPHRASE_LENGTH 64
28#define P2P_NAME_LENGTH 33
29#define INTERFACE_LENGTH 16
30#define DEVICE_TYPE_LENGTH 128
31#define MAX_DEVICES_NUM 256
32#define IP_ADDR_STR_LEN 16
33
34typedef enum GroupOwnerBand {
35    GO_BAND_AUTO,
36    GO_BAND_2GHZ,
37    GO_BAND_5GHZ
38} GroupOwnerBand;
39
40typedef struct WifiP2pConfig {
41    unsigned char devAddr[COMMON_MAC_LEN]; /* the device MAC address */
42    int bssidType; /* bssid type */
43    GroupOwnerBand goBand;
44    int netId; /* network id, when -2 means persistent and -1 means temporary, else need >= 0 */
45    char passphrase[PASSPHRASE_LENGTH]; /* the value ranges from 8 to 63. */
46    int groupOwnerIntent; /* the value is -1.(A value of -1 indicates the system can choose an appropriate value.) */
47    char groupName[P2P_NAME_LENGTH]; /* the value ranges from 1 to 32. */
48} WifiP2pConfig;
49
50typedef enum P2pGroupStatus {
51    GS_CREATING,
52    GS_CREATED,
53    GS_STARTED,
54    GS_REMOVING,
55    GS_INVALID
56} P2pGroupStatus;
57
58typedef enum P2pDeviceStatus {
59    PDS_CONNECTED,
60    PDS_INVITED,
61    PDS_FAILED,
62    PDS_AVAILABLE,
63    PDS_UNAVAILABLE
64} P2pDeviceStatus;
65
66typedef enum P2pState {
67    P2P_STATE_NONE = 0,
68    P2P_STATE_IDLE,
69    P2P_STATE_STARTING,
70    P2P_STATE_STARTED,
71    P2P_STATE_CLOSING,
72    P2P_STATE_CLOSED,
73} P2pState;
74
75typedef enum P2pConnectionState {
76    P2P_DISCONNECTED = 0,
77    P2P_CONNECTED,
78} P2pConnectionState;
79
80typedef struct WifiP2pWfdInfo {
81    int wfdEnabled; /* 0: false, 1: true */
82    int deviceInfo;
83    int ctrlPort;
84    int maxThroughput;
85} WifiP2pWfdInfo;
86
87typedef struct WifiP2pDevice {
88    char deviceName[P2P_NAME_LENGTH]; /* the value range is 0 to 32 characters. */
89    unsigned char devAddr[COMMON_MAC_LEN]; /* the device MAC address */
90    unsigned char randomDevAddr[COMMON_MAC_LEN]; /* the device MAC address */
91    int bssidType; /* bssid type. */
92    char primaryDeviceType[DEVICE_TYPE_LENGTH];
93    char secondaryDeviceType[DEVICE_TYPE_LENGTH];
94    P2pDeviceStatus status;
95    WifiP2pWfdInfo wfdInfo;
96    unsigned int supportWpsConfigMethods;
97    int deviceCapabilitys;
98    int groupCapabilitys;
99} WifiP2pDevice;
100
101typedef struct WifiP2pGroupInfo {
102    WifiP2pDevice owner;
103    int isP2pGroupOwner; /* 0: false, 1: true */
104    char passphrase[PASSPHRASE_LENGTH]; /* the value ranges from 8 to 63. */
105    char interface[INTERFACE_LENGTH];
106    char groupName[P2P_NAME_LENGTH];
107    int networkId;
108    int frequency; /* for example : freq=2412 to select 2.4 GHz channel 1.(Based on 2.4 GHz or 5 GHz) */
109    int isP2pPersistent; /* 0: false, 1: true */
110    P2pGroupStatus groupStatus;
111    WifiP2pDevice clientDevices[MAX_DEVICES_NUM];
112    int clientDevicesSize; /* the true size of clientDevices array */
113    char goIpAddress[IP_ADDR_STR_LEN];
114} WifiP2pGroupInfo;
115
116typedef struct WifiP2pLinkedInfo {
117    P2pConnectionState connectState;
118    int isP2pGroupOwner;
119    unsigned char groupOwnerAddress[COMMON_MAC_LEN];
120} WifiP2pLinkedInfo;
121#ifdef __cplusplus
122}
123#endif
124
125#endif
126