1 /* 2 * Copyright (c) 2025 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 WIFI_DIRECT_MANAGER_STRUCT_H 16 #define WIFI_DIRECT_MANAGER_STRUCT_H 17 18 #include "common_list.h" 19 #include "wifi_direct_types_struct.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 struct WifiDirectStatusListener { 26 void (*onLocalRoleChange)(enum WifiDirectRole oldRole, enum WifiDirectRole newRole); 27 void (*onDeviceOnLine)(const char *remoteMac, const char *remoteIp, const char *remoteUuid, bool isSource); 28 void (*onDeviceOffLine)(const char *remoteMac, const char *remoteIp, const char *remoteUuid, const char *localIp); 29 void (*onConnectedForSink)(const struct WifiDirectSinkLink *link); 30 void (*onDisconnectedForSink)(const struct WifiDirectSinkLink *link); 31 }; 32 33 typedef void (*SyncPtkListener)(const char *remoteDeviceId, int result); 34 typedef void (*PtkMismatchListener)(const char *remoteNetworkId, uint32_t len, int32_t reason); 35 typedef void (*HmlStateListener)(SoftBusHmlState state); 36 typedef void (*FrequencyChangedListener)(int32_t frequency); 37 struct WifiDirectEnhanceManager { 38 int32_t (*savePTK)(const char *remoteDeviceId, const char *ptk); 39 int32_t (*syncPTK)(const char *remoteDeviceId); 40 }; 41 42 struct WifiDirectManager { 43 uint32_t (*getRequestId)(void); 44 int32_t (*allocateListenerModuleId)(void); 45 void (*freeListenerModuleId)(int32_t moduleId); 46 47 int32_t (*connectDevice)(struct WifiDirectConnectInfo *info, struct WifiDirectConnectCallback *callback); 48 int32_t (*cancelConnectDevice)(const struct WifiDirectConnectInfo *info); 49 int32_t (*disconnectDevice)(struct WifiDirectDisconnectInfo *info, struct WifiDirectDisconnectCallback *callback); 50 int32_t (*forceDisconnectDevice)( 51 struct WifiDirectForceDisconnectInfo *info, struct WifiDirectDisconnectCallback *callback); 52 int32_t (*forceDisconnectDeviceSync)(enum WifiDirectLinkType wifiDirectLinkType); 53 void (*registerStatusListener)(struct WifiDirectStatusListener *listener); 54 int32_t (*prejudgeAvailability)(const char *remoteNetworkId, enum WifiDirectLinkType linkType); 55 bool (*isNoneLinkByType)(enum WifiDirectLinkType linkType); 56 57 bool (*isNegotiateChannelNeeded)(const char *remoteNetworkId, enum WifiDirectLinkType linkType); 58 void (*refreshRelationShip)(const char *remoteUuid, const char *remoteMac); 59 bool (*linkHasPtk)(const char *remoteDeviceId); 60 int32_t (*savePTK)(const char *remoteDeviceId, const char *ptk); 61 int32_t (*syncPTK)(const char *remoteDeviceId); 62 void (*addSyncPtkListener)(SyncPtkListener listener); 63 void (*addPtkMismatchListener)(PtkMismatchListener listener); 64 void (*addHmlStateListener)(HmlStateListener listener); 65 66 bool (*isDeviceOnline)(const char *remoteMac); 67 int32_t (*getLocalIpByUuid)(const char *uuid, char *localIp, int32_t localIpSize); 68 int32_t (*getLocalIpByRemoteIp)(const char *remoteIp, char *localIp, int32_t localIpSize); 69 int32_t (*getRemoteUuidByIp)(const char *remoteIp, char *uuid, int32_t uuidSize); 70 int32_t (*getLocalAndRemoteMacByLocalIp)( 71 const char *localIp, char *localMac, size_t localMacSize, char *remoteMac, size_t remoteMacSize); 72 int32_t (*getLocalAndRemoteMacByRemoteIp)( 73 const char *remoteIp, char *localMac, size_t localMacSize, char *remoteMac, size_t remoteMacSize); 74 75 bool (*supportHmlTwo)(void); 76 bool (*isWifiP2pEnabled)(void); 77 int (*getStationFrequency)(void); 78 bool (*isHmlConnected)(void); 79 HmlCapabilityCode (*getHmlCapabilityCode)(void); 80 VirtualLinkCapabilityCode (*getVirtualLinkCapabilityCode)(void); 81 VspCapabilityCode (*getVspCapabilityCode)(void); 82 83 int32_t (*init)(void); 84 85 /* for private inner usage */ 86 void (*notifyOnline)(const char *remoteMac, const char *remoteIp, const char *remoteUuid, bool isSource); 87 void (*notifyOffline)(const char *remoteMac, const char *remoteIp, const char *remoteUuid, const char *localIp); 88 void (*notifyRoleChange)(enum WifiDirectRole oldRole, enum WifiDirectRole newRole); 89 void (*notifyConnectedForSink)(const struct WifiDirectSinkLink *link); 90 void (*notifyDisconnectedForSink)(const struct WifiDirectSinkLink *link); 91 void (*registerEnhanceManager)(struct WifiDirectEnhanceManager *manager); 92 void (*notifyPtkSyncResult)(const char *remoteDeviceId, int result); 93 void (*notifyPtkMismatch)(const char *remoteNetworkId, uint32_t len, int32_t reason); 94 void (*notifyHmlState)(SoftBusHmlState state); 95 int32_t (*getRemoteIpByRemoteMac)(const char *remoteMac, char *remoteIp, int32_t remoteIpSize); 96 97 /* for virtual connection */ 98 void (*addFrequencyChangedListener)(FrequencyChangedListener listener); 99 void (*notifyFrequencyChanged)(int32_t frequency); 100 bool (*checkOnlyVirtualLink)(void); 101 void (*checkAndForceDisconnectVirtualLink)(void); 102 int32_t (*getHmlLinkCount)(void); 103 }; 104 105 #ifdef __cplusplus 106 } 107 #endif 108 #endif 109