1 /* 2 * Copyright (c) 2021 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 P2PLINK_ADAPTER_H 17 #define P2PLINK_ADAPTER_H 18 19 #include <stdbool.h> 20 #include <stdint.h> 21 22 #include "p2plink_type.h" 23 24 #ifdef __cplusplus 25 #if __cplusplus 26 extern "C" { 27 #endif 28 #endif 29 30 typedef struct { 31 char mac[P2P_MAC_LEN]; 32 } P2pLinkPeerMacList; 33 34 typedef struct { 35 P2pLinkRole role; 36 int32_t peerMacNum; 37 char peerMacs[0]; 38 } P2pLinkGroup; 39 40 typedef struct { 41 int32_t num; 42 int32_t chans[0]; 43 } P2pLink5GList; 44 45 typedef enum { 46 P2PLINK_CONNECTING, 47 P2PLINK_CONNECTED, 48 P2PLINK_CONNECT_FAILED, 49 } P2pLinkConnState; 50 51 typedef struct { 52 void (*p2pStateChanged)(bool state); 53 void (*groupStateChanged)(const P2pLinkGroup *group); 54 void (*connResult)(P2pLinkConnState state); 55 void (*wifiCfgChanged)(const char *cfgData); 56 void (*enterDiscState)(void); 57 } BroadcastRecvCb; 58 59 int32_t P2pLinkAdapterInit(const BroadcastRecvCb *cb); 60 int32_t P2pLinkGetP2pIpAddress(char *ip, int32_t len); 61 int32_t P2pLinkGetBaseMacAddress(char *mac, int32_t len); 62 int32_t P2pLinkCreateGroup(int32_t freq, bool isWideBandSupport); 63 int32_t P2pLinkGetRecommendChannel(int32_t *freq); 64 int32_t P2pLinkConnectGroup(const char *groupConfig); 65 int32_t P2pLinkRequestGcIp(const char* mac, char *ip, int32_t len); 66 int32_t P2pLinkConfigGcIp(const char *ip); 67 int32_t P2pLinkGetSelfWifiCfgInfo(char *cfgData, int32_t len); 68 int32_t P2pLinkSetPeerWifiCfgInfo(const char *cfgData); 69 int32_t P2pLinkSharelinkReuse(void); 70 int32_t P2pLinkSharelinkRemoveGroup(void); 71 int32_t P2pLinkGetWifiState(void); 72 int32_t P2pLinkReleaseIPAddr(void); 73 int32_t P2pLinkGetFrequency(void); 74 75 P2pLinkGroup *P2pLinkRequetGroupInfo(void); 76 P2pLink5GList *P2pLinkGetChannelListFor5G(void); 77 78 char *P2pLinkGetGroupConfigInfo(void); 79 bool P2pLinkIsWideBandwidthSupported(void); 80 81 void P2pLinkStopPeerDiscovery(void); 82 void P2pLinkRemoveGroup(void); 83 void P2pLinkRemoveGcGroup(void); 84 85 #ifdef __cplusplus 86 #if __cplusplus 87 } 88 #endif /* __cplusplus */ 89 #endif /* __cplusplus */ 90 #endif /* P2PLINK_ADAPTER_H */ 91