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