1 /* 2 * Copyright (C) 2021-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_WIFI_HAL_P2P_STRUCT_H 17 #define OHOS_WIFI_HAL_P2P_STRUCT_H 18 19 #include "wifi_hal_define.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 typedef enum P2pSupplicantErrCode { 25 P2P_SUP_ERRCODE_SUCCESS = 0, 26 P2P_SUP_ERRCODE_FAILED = 1, 27 P2P_SUP_ERRCODE_TIMEOUT = 2, 28 P2P_SUP_ERRCODE_PBC_OVERLAP = 3, 29 P2P_SUP_ERRCODE_UNKNOWN = 4, 30 P2P_SUP_ERRCODE_INPUT_ERROR = 5, 31 P2P_SUP_ERRCODE_INVALID = 0XFF, 32 } P2pSupplicantErrCode; 33 34 #define WIFI_P2P_DEVICE_TYPE_LENGTH 64 35 #define WIFI_P2P_DEVICE_NAME_LENGTH 128 36 #define WIFI_P2P_WFD_DEVICE_INFO_LENGTH 128 37 #define WIFI_P2P_PASSWORD_SIZE 128 38 39 typedef struct P2pDeviceInfo { 40 short configMethods; 41 int deviceCapabilities; 42 int groupCapabilities; 43 unsigned int wfdLength; 44 char srcAddress[WIFI_BSSID_LENGTH]; 45 char p2pRandomDeviceAddress[WIFI_BSSID_LENGTH]; 46 char p2pDeviceAddress[WIFI_BSSID_LENGTH]; 47 char p2pGroupAddress[WIFI_BSSID_LENGTH]; 48 char primaryDeviceType[WIFI_P2P_DEVICE_TYPE_LENGTH]; 49 char deviceName[WIFI_P2P_DEVICE_NAME_LENGTH]; 50 char wfdDeviceInfo[WIFI_P2P_WFD_DEVICE_INFO_LENGTH]; 51 char operSsid[WIFI_P2P_DEVICE_NAME_LENGTH]; 52 } P2pDeviceInfo; 53 54 typedef struct P2pGroupInfo { 55 int isGo; 56 int isPersistent; 57 int frequency; 58 char groupIfName[WIFI_P2P_GROUP_IFNAME_LENGTH]; 59 char ssid[WIFI_SSID_LENGTH]; 60 char psk[WIFI_P2P_PASSWORD_SIZE]; 61 char passphrase[WIFI_P2P_PASSWORD_SIZE]; 62 char goDeviceAddress[WIFI_BSSID_LENGTH]; 63 char goRandomDeviceAddress[WIFI_BSSID_LENGTH]; 64 } P2pGroupInfo; 65 66 typedef struct P2pInvitationInfo { 67 int type; 68 int persistentNetworkId; 69 int operatingFrequency; 70 char srcAddress[WIFI_BSSID_LENGTH]; 71 char goDeviceAddress[WIFI_BSSID_LENGTH]; 72 char bssid[WIFI_BSSID_LENGTH]; 73 } P2pInvitationInfo; 74 75 typedef struct P2pServDiscRespInfo { 76 short updateIndicator; 77 char srcAddress[WIFI_BSSID_LENGTH]; 78 char *tlvs; 79 } P2pServDiscRespInfo; 80 81 typedef struct P2pConnectInfo { 82 int persistent; // persistent=<network id>] 83 int mode; // [join|auth] 84 int goIntent; // [go_intent=<0..15>] 85 int provdisc; // [provdisc] 86 char peerDevAddr[WIFI_BSSID_LENGTH]; 87 char pin[WIFI_PIN_CODE_LENGTH + 1]; // <pbc|pin|PIN#|p2ps> 88 } P2pConnectInfo; 89 90 typedef struct P2pNetworkInfo { 91 int id; 92 char ssid[WIFI_SSID_LENGTH]; 93 char bssid[WIFI_BSSID_LENGTH]; 94 char flags[WIFI_NETWORK_FLAGS_LENGTH]; 95 } P2pNetworkInfo; 96 97 typedef struct P2pNetworkList { 98 int infoNum; 99 P2pNetworkInfo *infos; 100 } P2pNetworkList; 101 102 typedef struct P2pServDiscReqInfo { 103 int freq; 104 int dialogToken; 105 int updateIndic; 106 char mac[WIFI_BSSID_LENGTH]; 107 char *tlvs; 108 } P2pServDiscReqInfo; 109 110 typedef struct P2pServiceInfo { 111 int mode; /* 0/1, upnp/bonjour */ 112 int version; 113 char name[WIFI_P2P_SERVER_NAME_LENGTH]; 114 char query[WIFI_P2P_SERVE_INFO_LENGTH]; 115 char resp[WIFI_P2P_SERVE_INFO_LENGTH]; 116 } P2pServiceInfo; 117 118 typedef struct P2pGroupConfig { 119 P2pGroupConfigType cfgParam; /* param */ 120 char cfgValue[WIFI_P2P_GROUP_CONFIG_VALUE_LENGTH]; /* param value */ 121 } P2pGroupConfig; 122 123 typedef struct P2pWpsPinDisplayArgv { 124 int mode; /* 0/1 : PIN_KEYPAD/PIN_DISPLAY */ 125 char pinCode[WIFI_PIN_CODE_LENGTH + 1]; 126 char bssid[WIFI_BSSID_LENGTH]; 127 } P2pWpsPinDisplayArgv; 128 129 typedef struct P2pHalInviteArgv { 130 int persistent; 131 char ifname[WIFI_P2P_GROUP_IFNAME_LENGTH]; 132 char peerbssid[WIFI_BSSID_LENGTH]; 133 char gobssid[WIFI_BSSID_LENGTH]; 134 } P2pHalInviteArgv; 135 136 typedef struct P2pHalReInviteArgv { 137 int networkId; 138 char peerbssid[WIFI_BSSID_LENGTH]; 139 } P2pHalReInviteArgv; 140 141 typedef struct P2pProvisionDiscoveryArgv { 142 char peerbssid[WIFI_BSSID_LENGTH]; 143 int mode; /* 0/1/2 : Pbc/display/keypad */ 144 } P2pProvisionDiscoveryArgv; 145 146 typedef struct P2pWpaGroupConfigArgv { 147 int id; /* network id */ 148 P2pGroupConfigType param; /* set network param */ 149 char value[WIFI_P2P_GROUP_CONFIG_VALUE_LENGTH]; /* set network value */ 150 } P2pWpaGroupConfigArgv; 151 152 typedef struct Hid2dConnectInfo { 153 char ssid[WIFI_SSID_LENGTH]; 154 char bssid[WIFI_BSSID_LENGTH]; 155 char passphrase[WIFI_P2P_PASSWORD_SIZE]; 156 int frequency; 157 int isLegacyGo; 158 } Hid2dConnectInfo; 159 160 #ifdef __cplusplus 161 } 162 #endif 163 #endif 164