• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
20 extern "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 
34 typedef enum GroupOwnerBand {
35     GO_BAND_AUTO,
36     GO_BAND_2GHZ,
37     GO_BAND_5GHZ
38 } GroupOwnerBand;
39 
40 typedef struct WifiP2pConfig {
41     unsigned char devAddr[COMMON_MAC_LEN]; /* the device MAC address */
42     GroupOwnerBand goBand;
43     int netId; /* network id, when -2 means persistent and -1 means temporary, else need >= 0 */
44     char passphrase[PASSPHRASE_LENGTH]; /* the value ranges from 8 to 63. */
45     int groupOwnerIntent; /* the value is -1.(A value of -1 indicates the system can choose an appropriate value.) */
46     char groupName[P2P_NAME_LENGTH]; /* the value ranges from 1 to 32. */
47 } WifiP2pConfig;
48 
49 typedef enum P2pGroupStatus {
50     GS_CREATING,
51     GS_CREATED,
52     GS_STARTED,
53     GS_REMOVING,
54     GS_INVALID
55 } P2pGroupStatus;
56 
57 typedef enum P2pDeviceStatus {
58     PDS_CONNECTED,
59     PDS_INVITED,
60     PDS_FAILED,
61     PDS_AVAILABLE,
62     PDS_UNAVAILABLE
63 } P2pDeviceStatus;
64 
65 typedef enum P2pState {
66     P2P_STATE_NONE = 0,
67     P2P_STATE_IDLE,
68     P2P_STATE_STARTING,
69     P2P_STATE_STARTED,
70     P2P_STATE_CLOSING,
71     P2P_STATE_CLOSED,
72 } P2pState;
73 
74 typedef enum P2pConnectionState {
75     P2P_DISCONNECTED = 0,
76     P2P_CONNECTED,
77 } P2pConnectionState;
78 
79 typedef struct WifiP2pWfdInfo {
80     int wfdEnabled; /* 0: false, 1: true */
81     int deviceInfo;
82     int ctrlPort;
83     int maxThroughput;
84 } WifiP2pWfdInfo;
85 
86 typedef struct WifiP2pDevice {
87     char deviceName[P2P_NAME_LENGTH]; /* the value range is 0 to 32 characters. */
88     unsigned char devAddr[COMMON_MAC_LEN]; /* the device MAC address */
89     char primaryDeviceType[DEVICE_TYPE_LENGTH];
90     char secondaryDeviceType[DEVICE_TYPE_LENGTH];
91     P2pDeviceStatus status;
92     WifiP2pWfdInfo wfdInfo;
93     unsigned int supportWpsConfigMethods;
94     int deviceCapabilitys;
95     int groupCapabilitys;
96 } WifiP2pDevice;
97 
98 typedef struct WifiP2pGroupInfo {
99     WifiP2pDevice owner;
100     int isP2pGroupOwner; /* 0: false, 1: true */
101     char passphrase[PASSPHRASE_LENGTH]; /* the value ranges from 8 to 63. */
102     char interface[INTERFACE_LENGTH];
103     char groupName[P2P_NAME_LENGTH];
104     int networkId;
105     int frequency; /* for example : freq=2412 to select 2.4 GHz channel 1.(Based on 2.4 GHz or 5 GHz) */
106     int isP2pPersistent; /* 0: false, 1: true */
107     P2pGroupStatus groupStatus;
108     WifiP2pDevice clientDevices[MAX_DEVICES_NUM];
109     int clientDevicesSize; /* the true size of clientDevices array */
110     char goIpAddress[IP_ADDR_STR_LEN];
111 } WifiP2pGroupInfo;
112 
113 typedef struct WifiP2pLinkedInfo {
114     P2pConnectionState connectState;
115     int isP2pGroupOwner;
116     unsigned char groupOwnerAddress[COMMON_MAC_LEN];
117 } WifiP2pLinkedInfo;
118 
119 #ifdef __cplusplus
120 }
121 #endif
122 
123 #endif
124