1 /* 2 * Copyright (c) 2023 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 #ifndef WPA_P2P_CMD_H 16 #define WPA_P2P_CMD_H 17 18 #include "../wpa_impl.h" 19 #include "wpa_client.h" 20 21 /** 22 * @brief Defines the enum for P2p Wps Method 23 * 24 * @since 4.1 25 * @version 1.0 26 */ 27 enum P2pWpsMethod { 28 P2P_WPS_METHOD_PBC, 29 P2P_WPS_METHOD_DISPLAY, 30 P2P_WPS_METHOD_KEYPAD, 31 P2P_WPS_METHOD_LABEL, 32 P2P_WPS_METHOD_INVALID 33 }; 34 35 enum P2pRemoveGroupEvent { 36 P2P_REMOVE_GROUP_CLIENT = 0, 37 EVENT_MAX 38 }; 39 40 int32_t WpaInterfaceP2pSetSsidPostfixName(struct IWpaInterface *self, const char *ifName, const char *name); 41 42 int32_t WpaInterfaceP2pSetWpsDeviceType(struct IWpaInterface *self, const char *ifName, const char *type); 43 44 int32_t WpaInterfaceP2pSetWpsConfigMethods(struct IWpaInterface *self, const char *ifName, const char *methods); 45 46 int32_t WpaInterfaceP2pSetGroupMaxIdle(struct IWpaInterface *self, const char *ifName, int32_t time); 47 48 int32_t WpaInterfaceP2pSetWfdEnable(struct IWpaInterface *self, const char *ifName, int32_t enable); 49 50 int32_t WpaInterfaceP2pSetPersistentReconnect(struct IWpaInterface *self, const char *ifName, int32_t status); 51 52 int32_t WpaInterfaceP2pSetWpsSecondaryDeviceType(struct IWpaInterface *self, const char *ifName, const char *type); 53 54 int32_t WpaInterfaceP2pSetupWpsPbc(struct IWpaInterface *self, const char *ifName, const char *address); 55 56 int32_t WpaInterfaceP2pSetupWpsPin(struct IWpaInterface *self, const char *ifName, const char *address, 57 const char *pin, char *result, uint32_t resultLen); 58 59 int32_t WpaInterfaceP2pSetPowerSave(struct IWpaInterface *self, const char *ifName, int32_t enable); 60 61 int32_t WpaInterfaceP2pSetDeviceName(struct IWpaInterface *self, const char *ifName, const char *name); 62 63 int32_t WpaInterfaceP2pSetWfdDeviceConfig(struct IWpaInterface *self, const char *ifName, const char *config); 64 65 int32_t WpaInterfaceP2pSetRandomMac(struct IWpaInterface *self, const char *ifName, int32_t networkId); 66 67 int32_t WpaInterfaceP2pStartFind(struct IWpaInterface *self, const char *ifName, int32_t timeout); 68 69 int32_t WpaInterfaceP2pSetExtListen(struct IWpaInterface *self, const char *ifName, int32_t enable, 70 int32_t period, int32_t interval); 71 72 int32_t WpaInterfaceP2pSetListenChannel(struct IWpaInterface *self, const char *ifName, int32_t channel, 73 int32_t regClass); 74 75 int32_t WpaInterfaceP2pProvisionDiscovery(struct IWpaInterface *self, const char *ifName, 76 const char *peerBssid, int32_t mode); 77 78 int32_t WpaInterfaceP2pAddGroup(struct IWpaInterface *self, const char *ifName, int32_t isPersistent, 79 int32_t networkId, int32_t freq); 80 81 int32_t WpaInterfaceP2pAddService(struct IWpaInterface *self, const char *ifName, 82 const struct HdiP2pServiceInfo *info); 83 84 int32_t WpaInterfaceP2pRemoveService(struct IWpaInterface *self, const char *ifName, 85 const struct HdiP2pServiceInfo *info); 86 87 int32_t WpaInterfaceP2pStopFind(struct IWpaInterface *self, const char *ifName); 88 89 int32_t WpaInterfaceP2pFlush(struct IWpaInterface *self, const char *ifName); 90 91 int32_t WpaInterfaceP2pFlushService(struct IWpaInterface *self, const char *ifName); 92 93 int32_t WpaInterfaceP2pRemoveNetwork(struct IWpaInterface *self, const char *ifName, int32_t networkId); 94 95 int32_t WpaInterfaceP2pSetGroupConfig(struct IWpaInterface *self, const char *ifName, 96 const int32_t networkId, const char *name, const char *value); 97 98 int32_t WpaInterfaceP2pInvite(struct IWpaInterface *self, const char *ifName, const char *peerBssid, 99 const char *goBssid); 100 101 int32_t WpaInterfaceP2pReinvoke(struct IWpaInterface *self, const char *ifName, const int32_t networkId, 102 const char *bssid); 103 104 int32_t WpaInterfaceP2pGetDeviceAddress(struct IWpaInterface *self, const char *ifName, char *deviceAddress, 105 uint32_t deviceAddressLen); 106 107 int32_t WpaInterfaceP2pReqServiceDiscovery(struct IWpaInterface *self, const char *ifName, 108 const struct HdiP2pReqService *reqService, char *replyDisc, uint32_t replyDiscLen); 109 110 int32_t WpaInterfaceP2pCancelServiceDiscovery(struct IWpaInterface *self, const char *ifName, const char *id); 111 112 int32_t WpaInterfaceP2pRespServerDiscovery(struct IWpaInterface *self, const char *ifName, 113 const struct HdiP2pServDiscReqInfo *info); 114 115 int32_t WpaInterfaceP2pConnect(struct IWpaInterface *self, const char *ifName, 116 const struct HdiP2pConnectInfo *info, char *replyPin, uint32_t replyPinLen); 117 118 int32_t WpaInterfaceP2pHid2dConnect(struct IWpaInterface *self, const char *ifName, 119 const struct HdiHid2dConnectInfo *info); 120 121 int32_t WpaInterfaceP2pSetServDiscExternal(struct IWpaInterface *self, const char *ifName, int32_t mode); 122 123 int32_t WpaInterfaceP2pRemoveGroup(struct IWpaInterface *self, const char *ifName, const char *groupName); 124 125 int32_t WpaInterfaceP2pCancelConnect(struct IWpaInterface *self, const char *ifName); 126 127 int32_t WpaInterfaceP2pGetGroupConfig(struct IWpaInterface *self, const char *ifName, 128 const int32_t networkId, const char *param, char *value, uint32_t valueLen); 129 130 int32_t WpaInterfaceP2pAddNetwork(struct IWpaInterface *self, const char *ifName, int32_t *networkId); 131 132 int32_t WpaInterfaceP2pGetPeer(struct IWpaInterface *self, const char *ifName, const char *bssid, 133 struct HdiP2pDeviceInfo *info); 134 135 int32_t WpaInterfaceP2pGetGroupCapability(struct IWpaInterface *self, const char *ifName, const char *bssid, 136 int32_t *cap); 137 138 int32_t WpaInterfaceP2pListNetworks(struct IWpaInterface *self, const char *ifName, 139 struct HdiP2pNetworkList *infoList); 140 141 int32_t WpaInterfaceP2pSaveConfig(struct IWpaInterface *self, const char *ifName); 142 143 int32_t WpaInterfaceVendorExtProcessCmd(struct IWpaInterface *self, const char *ifName, const char *cmd); 144 145 int32_t WpaInterfaceDeliverP2pData(struct IWpaInterface *self, const char *ifName, 146 int32_t cmdType, int32_t dataType, const char *carryData); 147 /** 148 * @brief Defines callback for P2p 149 * 150 * @since 4.1 151 * @version 1.0 152 */ 153 int32_t ProcessEventP2pDeviceFound(struct HdfWpaRemoteNode *node, 154 struct P2pDeviceInfoParam *deviceInfoParam, const char *ifName); 155 156 int32_t ProcessEventP2pDeviceLost(struct HdfWpaRemoteNode *node, 157 struct P2pDeviceLostParam *deviceLostParam, const char *ifName); 158 159 int32_t ProcessEventP2pGoNegotiationRequest(struct HdfWpaRemoteNode *node, 160 struct P2pGoNegotiationRequestParam *goNegotiationRequestParam, const char *ifName); 161 162 int32_t ProcessEventP2pGoNegotiationCompleted(struct HdfWpaRemoteNode *node, 163 struct P2pGoNegotiationCompletedParam *goNegotiationCompletedParam, const char *ifName); 164 165 int32_t ProcessEventP2pInvitationReceived(struct HdfWpaRemoteNode *node, 166 struct P2pInvitationReceivedParam *invitationReceivedParam, const char *ifName); 167 168 int32_t ProcessEventP2pInvitationResult(struct HdfWpaRemoteNode *node, 169 struct P2pInvitationResultParam *invitationResultParam, const char *ifName); 170 171 int32_t ProcessEventP2pGroupFormationSuccess(struct HdfWpaRemoteNode *node, 172 const char *ifName); 173 174 int32_t ProcessEventP2pGroupFormationFailure(struct HdfWpaRemoteNode *node, char *reason, 175 const char *ifName); 176 177 int32_t ProcessEventP2pGroupStarted(struct HdfWpaRemoteNode *node, 178 struct P2pGroupStartedParam *groupStartedParam, const char *ifName); 179 180 int32_t ProcessEventP2pGroupRemoved(struct HdfWpaRemoteNode *node, 181 struct P2pGroupRemovedParam *groupRemovedParam, const char *ifName); 182 183 int32_t ProcessEventP2pProvisionDiscoveryCompleted(struct HdfWpaRemoteNode *node, 184 struct P2pProvisionDiscoveryCompletedParam *provisionDiscoveryCompletedParam, const char *ifName); 185 186 int32_t ProcessEventP2pFindStopped(struct HdfWpaRemoteNode *node, 187 const char *ifName); 188 189 int32_t ProcessEventP2pServDiscReq(struct HdfWpaRemoteNode *node, 190 struct P2pServDiscReqInfoParam *servDiscReqInfo, const char *ifName); 191 192 int32_t ProcessEventP2pServDiscResp(struct HdfWpaRemoteNode *node, 193 struct P2pServDiscRespParam *servDiscRespParam, const char *ifName); 194 195 int32_t ProcessEventP2pStaConnectState(struct HdfWpaRemoteNode *node, 196 struct P2pStaConnectStateParam *staConnectStateParam, const char *ifName); 197 198 int32_t ProcessEventP2pIfaceCreated(struct HdfWpaRemoteNode *node, struct P2pIfaceCreatedParam *ifaceCreatedParam, 199 const char *ifName); 200 201 #endif 202