1094332d3Sopenharmony_ci/* 2094332d3Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License. 5094332d3Sopenharmony_ci * You may obtain a copy of the License at 6094332d3Sopenharmony_ci * 7094332d3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8094332d3Sopenharmony_ci * 9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and 13094332d3Sopenharmony_ci * limitations under the License. 14094332d3Sopenharmony_ci */ 15094332d3Sopenharmony_ci#include <securec.h> 16094332d3Sopenharmony_ci#include <hdf_base.h> 17094332d3Sopenharmony_ci#include <hdf_log.h> 18094332d3Sopenharmony_ci#include <osal_time.h> 19094332d3Sopenharmony_ci#include <osal_mem.h> 20094332d3Sopenharmony_ci#include "v1_1/iwpa_callback.h" 21094332d3Sopenharmony_ci#include "v1_1/iwpa_interface.h" 22094332d3Sopenharmony_ci#include "wpa_common_cmd.h" 23094332d3Sopenharmony_ci#include "wpa_p2p_cmd.h" 24094332d3Sopenharmony_ci#include "wpa_impl.h" 25094332d3Sopenharmony_ci 26094332d3Sopenharmony_cistruct WpaInterfaceService { 27094332d3Sopenharmony_ci struct IWpaInterface interface; 28094332d3Sopenharmony_ci}; 29094332d3Sopenharmony_ci 30094332d3Sopenharmony_cistruct IWpaInterface *WpaInterfaceImplGetInstance(void) 31094332d3Sopenharmony_ci{ 32094332d3Sopenharmony_ci struct WpaInterfaceService *service = (struct WpaInterfaceService *)OsalMemCalloc( 33094332d3Sopenharmony_ci sizeof(struct WpaInterfaceService)); 34094332d3Sopenharmony_ci if (service == NULL) { 35094332d3Sopenharmony_ci HDF_LOGE("%{public}s: malloc WpaInterfaceService obj failed!", __func__); 36094332d3Sopenharmony_ci return NULL; 37094332d3Sopenharmony_ci } 38094332d3Sopenharmony_ci 39094332d3Sopenharmony_ci service->interface.Start = WpaInterfaceStart; 40094332d3Sopenharmony_ci service->interface.Stop = WpaInterfaceStop; 41094332d3Sopenharmony_ci service->interface.AddWpaIface = WpaInterfaceAddWpaIface; 42094332d3Sopenharmony_ci service->interface.RemoveWpaIface = WpaInterfaceRemoveWpaIface; 43094332d3Sopenharmony_ci service->interface.Scan = WpaInterfaceScan; 44094332d3Sopenharmony_ci service->interface.ScanResult= WpaInterfaceScanResult; 45094332d3Sopenharmony_ci service->interface.AddNetwork = WpaInterfaceAddNetwork; 46094332d3Sopenharmony_ci service->interface.RemoveNetwork = WpaInterfaceRemoveNetwork; 47094332d3Sopenharmony_ci service->interface.DisableNetwork = WpaInterfaceDisableNetwork; 48094332d3Sopenharmony_ci service->interface.SetNetwork = WpaInterfaceSetNetwork; 49094332d3Sopenharmony_ci service->interface.ListNetworks = WpaInterfaceListNetworks; 50094332d3Sopenharmony_ci service->interface.SelectNetwork = WpaInterfaceSelectNetwork; 51094332d3Sopenharmony_ci service->interface.EnableNetwork = WpaInterfaceEnableNetwork; 52094332d3Sopenharmony_ci service->interface.Reconnect = WpaInterfaceReconnect; 53094332d3Sopenharmony_ci service->interface.Disconnect = WpaInterfaceDisconnect; 54094332d3Sopenharmony_ci service->interface.SetPowerSave = WpaInterfaceSetPowerSave; 55094332d3Sopenharmony_ci service->interface.AutoConnect = WpaInterfaceAutoConnect; 56094332d3Sopenharmony_ci service->interface.WifiStatus = WpaInterfaceWifiStatus; 57094332d3Sopenharmony_ci service->interface.SaveConfig = WpaInterfaceSaveConfig; 58094332d3Sopenharmony_ci service->interface.WpsPbcMode = WpaInterfaceWpsPbcMode; 59094332d3Sopenharmony_ci service->interface.WpsPinMode = WpaInterfaceWpsPinMode; 60094332d3Sopenharmony_ci service->interface.WpsCancel = WpaInterfaceWpsCancel; 61094332d3Sopenharmony_ci service->interface.GetCountryCode = WpaInterfaceGetCountryCode; 62094332d3Sopenharmony_ci service->interface.GetNetwork = WpaInterfaceGetNetwork; 63094332d3Sopenharmony_ci service->interface.BlocklistClear = WpaInterfaceBlocklistClear; 64094332d3Sopenharmony_ci service->interface.SetSuspendMode = WpaInterfaceSetSuspendMode; 65094332d3Sopenharmony_ci service->interface.RegisterEventCallback = WpaInterfaceRegisterEventCallback; 66094332d3Sopenharmony_ci service->interface.UnregisterEventCallback = WpaInterfaceUnregisterEventCallback; 67094332d3Sopenharmony_ci service->interface.RegisterWpaEventCallback = WpaInterfaceRegisterEventCallback; 68094332d3Sopenharmony_ci service->interface.UnregisterWpaEventCallback = WpaInterfaceUnregisterEventCallback; 69094332d3Sopenharmony_ci service->interface.GetConnectionCapabilities = WpaInterfaceGetConnectionCapabilities; 70094332d3Sopenharmony_ci service->interface.GetScanSsid = WpaInterfaceGetScanSsid; 71094332d3Sopenharmony_ci service->interface.GetPskPassphrase = WpaInterfaceGetPskPassphrase; 72094332d3Sopenharmony_ci service->interface.GetPsk = WpaInterfaceGetPsk; 73094332d3Sopenharmony_ci service->interface.GetWepKey = WpaInterfaceGetWepKey; 74094332d3Sopenharmony_ci service->interface.GetWepTxKeyIdx = WpaInterfaceGetWepTxKeyIdx; 75094332d3Sopenharmony_ci service->interface.GetRequirePmf = WpaInterfaceGetRequirePmf; 76094332d3Sopenharmony_ci service->interface.SetCountryCode = WpaInterfaceSetCountryCode; 77094332d3Sopenharmony_ci service->interface.Reassociate = WpaInterfaceReassociate; 78094332d3Sopenharmony_ci service->interface.StaShellCmd = WpaInterfaceStaShellCmd; 79094332d3Sopenharmony_ci 80094332d3Sopenharmony_ci service->interface.P2pSetSsidPostfixName = WpaInterfaceP2pSetSsidPostfixName; 81094332d3Sopenharmony_ci service->interface.P2pSetWpsDeviceType = WpaInterfaceP2pSetWpsDeviceType; 82094332d3Sopenharmony_ci service->interface.P2pSetWpsConfigMethods = WpaInterfaceP2pSetWpsConfigMethods; 83094332d3Sopenharmony_ci service->interface.P2pSetGroupMaxIdle = WpaInterfaceP2pSetGroupMaxIdle; 84094332d3Sopenharmony_ci service->interface.P2pSetWfdEnable = WpaInterfaceP2pSetWfdEnable; 85094332d3Sopenharmony_ci service->interface.P2pSetPersistentReconnect = WpaInterfaceP2pSetPersistentReconnect; 86094332d3Sopenharmony_ci service->interface.P2pSetWpsSecondaryDeviceType = WpaInterfaceP2pSetWpsSecondaryDeviceType; 87094332d3Sopenharmony_ci service->interface.P2pSetupWpsPbc = WpaInterfaceP2pSetupWpsPbc; 88094332d3Sopenharmony_ci service->interface.P2pSetupWpsPin = WpaInterfaceP2pSetupWpsPin; 89094332d3Sopenharmony_ci service->interface.P2pSetPowerSave = WpaInterfaceP2pSetPowerSave; 90094332d3Sopenharmony_ci service->interface.P2pSetDeviceName = WpaInterfaceP2pSetDeviceName; 91094332d3Sopenharmony_ci service->interface.P2pSetWfdDeviceConfig = WpaInterfaceP2pSetWfdDeviceConfig; 92094332d3Sopenharmony_ci service->interface.P2pSetRandomMac = WpaInterfaceP2pSetRandomMac; 93094332d3Sopenharmony_ci service->interface.P2pStartFind = WpaInterfaceP2pStartFind; 94094332d3Sopenharmony_ci service->interface.P2pSetExtListen = WpaInterfaceP2pSetExtListen; 95094332d3Sopenharmony_ci service->interface.P2pSetListenChannel = WpaInterfaceP2pSetListenChannel; 96094332d3Sopenharmony_ci service->interface.P2pProvisionDiscovery = WpaInterfaceP2pProvisionDiscovery; 97094332d3Sopenharmony_ci service->interface.P2pAddGroup = WpaInterfaceP2pAddGroup; 98094332d3Sopenharmony_ci service->interface.P2pAddService = WpaInterfaceP2pAddService; 99094332d3Sopenharmony_ci service->interface.P2pRemoveService = WpaInterfaceP2pRemoveService; 100094332d3Sopenharmony_ci service->interface.P2pStopFind = WpaInterfaceP2pStopFind; 101094332d3Sopenharmony_ci service->interface.P2pFlush = WpaInterfaceP2pFlush; 102094332d3Sopenharmony_ci service->interface.P2pFlushService = WpaInterfaceP2pFlushService; 103094332d3Sopenharmony_ci service->interface.P2pRemoveNetwork = WpaInterfaceP2pRemoveNetwork; 104094332d3Sopenharmony_ci service->interface.P2pSetGroupConfig = WpaInterfaceP2pSetGroupConfig; 105094332d3Sopenharmony_ci service->interface.P2pInvite = WpaInterfaceP2pInvite; 106094332d3Sopenharmony_ci service->interface.P2pReinvoke = WpaInterfaceP2pReinvoke; 107094332d3Sopenharmony_ci service->interface.P2pGetDeviceAddress = WpaInterfaceP2pGetDeviceAddress; 108094332d3Sopenharmony_ci service->interface.P2pReqServiceDiscovery = WpaInterfaceP2pReqServiceDiscovery; 109094332d3Sopenharmony_ci service->interface.P2pCancelServiceDiscovery = WpaInterfaceP2pCancelServiceDiscovery; 110094332d3Sopenharmony_ci service->interface.P2pRespServerDiscovery = WpaInterfaceP2pRespServerDiscovery; 111094332d3Sopenharmony_ci service->interface.P2pConnect = WpaInterfaceP2pConnect; 112094332d3Sopenharmony_ci service->interface.P2pHid2dConnect = WpaInterfaceP2pHid2dConnect; 113094332d3Sopenharmony_ci service->interface.P2pSetServDiscExternal = WpaInterfaceP2pSetServDiscExternal; 114094332d3Sopenharmony_ci service->interface.P2pRemoveGroup = WpaInterfaceP2pRemoveGroup; 115094332d3Sopenharmony_ci service->interface.P2pCancelConnect = WpaInterfaceP2pCancelConnect; 116094332d3Sopenharmony_ci service->interface.P2pGetGroupConfig = WpaInterfaceP2pGetGroupConfig; 117094332d3Sopenharmony_ci service->interface.P2pAddNetwork = WpaInterfaceP2pAddNetwork; 118094332d3Sopenharmony_ci service->interface.P2pGetPeer = WpaInterfaceP2pGetPeer; 119094332d3Sopenharmony_ci service->interface.P2pGetGroupCapability = WpaInterfaceP2pGetGroupCapability; 120094332d3Sopenharmony_ci service->interface.P2pListNetworks = WpaInterfaceP2pListNetworks; 121094332d3Sopenharmony_ci service->interface.DeliverP2pData = WpaInterfaceDeliverP2pData; 122094332d3Sopenharmony_ci service->interface.P2pSaveConfig = WpaInterfaceP2pSaveConfig; 123094332d3Sopenharmony_ci 124094332d3Sopenharmony_ci service->interface.VendorProcessCmd = WpaInterfaceVendorExtProcessCmd; 125094332d3Sopenharmony_ci 126094332d3Sopenharmony_ci return &service->interface; 127094332d3Sopenharmony_ci} 128094332d3Sopenharmony_ci 129094332d3Sopenharmony_civoid WpaInterfaceImplRelease(struct IWpaInterface *instance) 130094332d3Sopenharmony_ci{ 131094332d3Sopenharmony_ci if (instance == NULL) { 132094332d3Sopenharmony_ci return; 133094332d3Sopenharmony_ci } 134094332d3Sopenharmony_ci OsalMemFree(instance); 135094332d3Sopenharmony_ci} 136