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 typedef struct { 25 char mac[P2P_MAC_LEN]; 26 } P2pLinkPeerMacList; 27 28 typedef struct { 29 P2pLinkRole role; 30 int32_t peerMacNum; 31 char peerMacs[0]; 32 } P2pLinkGroup; 33 34 typedef struct { 35 int32_t num; 36 int32_t chans[0]; 37 } P2pLink5GList; 38 39 typedef enum { 40 P2PLINK_CONNECTING, 41 P2PLINK_CONNECTED, 42 P2PLINK_CONNECT_FAILED, 43 } P2pLinkConnState; 44 45 typedef struct { 46 void (*p2pStateChanged)(bool state); 47 void (*groupStateChanged)(const P2pLinkGroup *group); 48 void (*connResult)(P2pLinkConnState state); 49 void (*wifiCfgChanged)(const char *cfgData); 50 void (*enterDiscState)(void); 51 } BroadcastRecvCb; 52 53 int32_t P2pLinkAdapterInit(const BroadcastRecvCb *cb); 54 int32_t P2pLinkGetP2pIpAddress(char *ip, int32_t len); 55 int32_t P2pLinkGetBaseMacAddress(char *mac, int32_t len); 56 int32_t P2pLinkCreateGroup(int32_t freq, bool isWideBandSupport); 57 int32_t P2pLinkGetRecommendChannel(int32_t *freq); 58 int32_t P2pLinkConnectGroup(const char *groupConfig); 59 int32_t P2pLinkRequestGcIp(const char* mac, char *ip, int32_t len); 60 int32_t P2pLinkConfigGcIp(const char *ip); 61 int32_t P2pLinkGetSelfWifiCfgInfo(char *cfgData, int32_t len); 62 int32_t P2pLinkSetPeerWifiCfgInfo(const char *cfgData); 63 int32_t P2pLinkSharelinkReuse(void); 64 int32_t P2pLinkSharelinkRemoveGroup(void); 65 int32_t P2pLinkGetWifiState(void); 66 int32_t P2pLinkReleaseIPAddr(void); 67 int32_t P2pLinkGetFrequency(void); 68 69 P2pLinkGroup *P2pLinkRequetGroupInfo(void); 70 P2pLink5GList *P2pLinkGetChannelListFor5G(void); 71 72 char *P2pLinkGetGroupConfigInfo(void); 73 bool P2pLinkIsWideBandwidthSupported(void); 74 75 void P2pLinkStopPeerDiscovery(void); 76 void P2pLinkRemoveGroup(void); 77 void P2pLinkRemoveGcGroup(void); 78 79 void P2pLinkEnableStub(void); 80 81 #endif 82