1 /*
2  * Copyright (C) 2021-2022 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 OHOS_WIFI_P2P_MSG_H
17 #define OHOS_WIFI_P2P_MSG_H
18 
19 #include <string>
20 #include <vector>
21 #include <climits>
22 #include "securec.h"
23 #include "wifi_common_msg.h"
24 
25 namespace OHOS {
26 namespace Wifi {
27 constexpr int WIFI_STR_MAC_LENGTH = 17;
28 constexpr int MAX_PASSPHRASE_LENGTH = 127;
29 constexpr int DEVICE_NAME_LENGTH = 32;
30 
31 enum class P2pGroupStatus { GS_CREATING, GS_CREATED, GS_STARTED, GS_REMOVING, GS_INVALID };
32 enum class P2pServiceStatus : unsigned char {
33     PSRS_SUCCESS,
34     PSRS_SERVICE_PROTOCOL_NOT_AVAILABLE,
35     PSRS_REQUESTED_INFORMATION_NOT_AVAILABLE,
36     PSRS_BAD_REQUEST,
37 };
38 
39 enum class P2pServicerProtocolType : unsigned char {
40     SERVICE_TYPE_ALL = 0,
41     SERVICE_TYPE_BONJOUR = 1,
42     SERVICE_TYPE_UP_NP = 2,
43     SERVICE_TYPE_WS_DISCOVERY = 3,
44     SERVICE_TYPE_VENDOR_SPECIFIC = 255,
45 };
46 
47 enum class P2pActionCallback : unsigned char {
48     DiscoverDevices,
49     StopDiscoverDevices,
50     DiscoverServices,
51     StopDiscoverServices,
52     PutLocalP2pService,
53     DeleteLocalP2pService,
54     RequestService,
55     StartP2pListen,
56     StopP2pListen,
57     CreateGroup,
58     RemoveGroup,
59     DeleteGroup,
60     P2pConnect,
61     P2pCancelConnect,
62     P2pSetDeviceName,
63     CreateHid2dGroup,
64     Hid2dConnect,
65     RemoveGroupClient,
66     DiscoverPeers,
67     UNKNOWN
68 };
69 
70 enum class P2pState {
71     P2P_STATE_NONE = 0,
72     P2P_STATE_IDLE,
73     P2P_STATE_STARTING,
74     P2P_STATE_STARTED,
75     P2P_STATE_CLOSING,
76     P2P_STATE_CLOSED,
77 };
78 
79 enum class P2pDiscoverState {
80     P2P_DISCOVER_NONE = 0,
81     P2P_DISCOVER_STARTING,
82     P2P_DISCOVER_CLOSED,
83 };
84 
85 enum class P2pConnectedState {
86     P2P_DISCONNECTED = 0,
87     P2P_CONNECTED,
88 };
89 
90 enum class P2pWfdInfoType {
91     WFD_SOURCE = 0x00,
92     PRIMARY_SINK = 0x01,
93     SECONDARY_SINK = 0x10,
94     SOURCE_OR_PRIMARY_SINK = 0x11
95 };
96 enum class P2pDeviceType {
97     DEVICE_TYPE = 0x3,
98     COUPLED_SINK_SUPPORT_AT_SOURCE = 0x4,
99     COUPLED_SINK_SUPPORT_AT_SINK = 0x8,
100     SESSION_AVAILABLE = 0x30,
101     SESSION_AVAILABLE_BIT1 = 0x10,
102     SESSION_AVAILABLE_BIT2 = 0x20
103 };
104 
105 enum class P2pDeviceStatus { PDS_CONNECTED, PDS_INVITED, PDS_FAILED, PDS_AVAILABLE, PDS_UNAVAILABLE };
106 
107 enum class WpsMethod { WPS_METHOD_PBC, WPS_METHOD_DISPLAY, WPS_METHOD_KEYPAD, WPS_METHOD_LABEL, WPS_METHOD_INVALID };
108 
109 enum class WpsConfigMethod {
110     WPS_CFG_INVALID = 0,
111     WPS_CFG_DISPLAY = 0x0008,
112     WPS_CFG_PUSHBUTTON = 0x0080,
113     WPS_CFG_KEYPAD = 0x0100,
114 };
115 
116 enum class P2pDeviceCapability {
117     PDC_SERVICE_DISCOVERY = 1,
118     PDC_CLIENT_DISCOVERABILITY = 1 << 1,
119     PDC_STARTED_CONCURRENT_OPER = 1 << 2,
120     PDC_REMOVING_INFRA_MANAGED = 1 << 3,
121     PDC_DEVICE_LIMIT = 1 << 4,
122     PDC_INVITATION_PROCEDURE = 1 << 5
123 };
124 
125 enum class P2pGroupCapability {
126     PGC_GROUP_OWNER = 1,
127     PGC_PERSISTENT_GROUP = 1 << 1,
128     PGC_GROUP_LIMIT = 1 << 2,
129     PGC_INTRA_BSS_DIST = 1 << 3,
130     PGC_CROSS_CONN = 1 << 4,
131     PGC_PERSISTENT_RECONN = 1 << 5,
132     PGC_GROUP_FORMATION = 1 << 6,
133     PGC_IP_ADDR_ALLOC = 1 << 7
134 };
135 
136 enum class P2pChrEvent {
137     INITIAL_VALUE = 0,
138     GO_NEGOTIATION_PEER_REJECT = 1,
139     GO_NEGOTIATION_WAIT_PEER_READY_TIMEOUT = 2,
140 };
141 
142 struct GcInfo {
143     std::string ip;
144     std::string mac;
145     std::string host;
146 };
147 
148 enum class GroupOwnerBand { GO_BAND_AUTO, GO_BAND_2GHZ, GO_BAND_5GHZ };
149 const int MAX_WFD_SUBELEMS = 12;
150 const char DeviceInfoSubelemLenHex[] = {"0006"};
151 class WifiP2pWfdInfo {
152 public:
WifiP2pWfdInfo()153     WifiP2pWfdInfo() : wfdEnabled(false), deviceInfo(0), ctrlPort(0), maxThroughput(0)
154     {}
WifiP2pWfdInfo(int info,int port,int throughput)155     WifiP2pWfdInfo(int info, int port, int throughput)
156         : wfdEnabled(true), deviceInfo(info), ctrlPort(port), maxThroughput(throughput)
157     {}
~WifiP2pWfdInfo()158     ~WifiP2pWfdInfo()
159     {}
160     void SetWfdEnabled(bool value);
161     bool GetWfdEnabled() const;
162     void SetDeviceInfo(int info);
163     int GetDeviceInfo() const;
164     void SetCtrlPort(int port);
165     int GetCtrlPort() const;
166     void SetMaxThroughput(int throughput);
167     int GetMaxThroughput() const;
168     bool isSessionAvailable();
169     void setSessionAvailable(bool enabled);
170     void GetDeviceInfoElement(std::string &subelement);
171 
172 private:
173     bool wfdEnabled;
174     int deviceInfo;
175     int ctrlPort;
176     int maxThroughput;
177 };
178 
179 class WifiP2pDevice {
180 public:
WifiP2pDevice()181     WifiP2pDevice()
182         : deviceName(""),
183           networkName(""),
184           mDeviceAddress(""),
185           deviceAddressType(REAL_DEVICE_ADDRESS),
186           primaryDeviceType(""),
187           secondaryDeviceType(""),
188           status(P2pDeviceStatus::PDS_UNAVAILABLE),
189           supportWpsConfigMethods(0),
190           deviceCapabilitys(0),
191           groupCapabilitys(0),
192           chrErrCode(P2pChrEvent::INITIAL_VALUE)
193     {}
~WifiP2pDevice()194     ~WifiP2pDevice()
195     {}
196     void SetDeviceName(const std::string &setDeviceName);
197     const std::string &GetDeviceName() const;
198     void SetNetworkName(const std::string &name);
199     const std::string &GetNetworkName() const;
200     void SetDeviceAddress(const std::string &deviceAddress);
201     void SetRandomDeviceAddress(const std::string &deviceAddress);
202     const std::string &GetDeviceAddress() const;
203     const std::string &GetRandomDeviceAddress() const;
204     void SetDeviceAddressType(int devAddressType);
205     int GetDeviceAddressType() const;
206     void SetPrimaryDeviceType(const std::string &setPrimaryDeviceType);
207     const std::string &GetPrimaryDeviceType() const;
208     void SetSecondaryDeviceType(const std::string &deviceType);
209     const std::string &GetSecondaryDeviceType() const;
210     void SetP2pDeviceStatus(P2pDeviceStatus setStatus);
211     P2pDeviceStatus GetP2pDeviceStatus() const;
212     void SetWfdInfo(const WifiP2pWfdInfo &info);
213     const WifiP2pWfdInfo &GetWfdInfo() const;
214     void SetWpsConfigMethod(unsigned int wpsConfigMethod);
215     unsigned int GetWpsConfigMethod() const;
216     void SetDeviceCapabilitys(int capabilitys);
217     int GetDeviceCapabilitys() const;
218     void SetGroupCapabilitys(int capabilitys);
219     int GetGroupCapabilitys() const;
220     bool IsGroupOwner() const;
221     bool IsGroupLimit() const;
222     bool IsDeviceLimit() const;
223     bool Isinviteable() const;
224     bool IsValid() const;
225     bool operator==(const WifiP2pDevice &cmp) const;
226     bool operator!=(const WifiP2pDevice &cmp) const;
227     bool WpsPbcSupported() const;
228     bool WpsDisplaySupported() const;
229     bool WpKeypadSupported() const;
230     void SetGroupAddress(const std::string &groupAddress);
231     const std::string &GetGroupAddress() const;
232     void SetChrErrCode(P2pChrEvent errCode);
233     P2pChrEvent GetChrErrCode() const;
234 
235 private:
236     std::string deviceName; /* the value range is 0 to 32 characters. */
237     std::string networkName; /* oper_ssid of peer device */
238     std::string mDeviceAddress; /* the device MAC address, the length is 17 characters. */
239     std::string mGroupAddress; /* the group MAC address, the length is 17 characters. */
240     std::string mRandomDeviceAddress; /* the device random MAC address, the length is 17 characters. */
241     int deviceAddressType; /* the device MAC address type */
242     std::string primaryDeviceType;
243     std::string secondaryDeviceType;
244     P2pDeviceStatus status;
245     WifiP2pWfdInfo wfdInfo;
246     unsigned int supportWpsConfigMethods;
247     int deviceCapabilitys;
248     int groupCapabilitys;
249     P2pChrEvent chrErrCode;
250 };
251 
252 const int TEMPORARY_NET_ID = -1;
253 const int PERSISTENT_NET_ID = -2;
254 const int INVALID_NET_ID = -999;
255 class WifiP2pGroupInfo {
256 public:
WifiP2pGroupInfo()257     WifiP2pGroupInfo()
258         : isP2pGroupOwner(false),
259           networkId(INVALID_NET_ID),
260           frequency(0),
261           isP2pPersistent(0),
262           groupStatus(P2pGroupStatus::GS_INVALID),
263           explicitGroup(false)
264     {}
~WifiP2pGroupInfo()265     ~WifiP2pGroupInfo()
266     {}
267     bool operator==(const WifiP2pGroupInfo &group) const;
268     bool operator!=(const WifiP2pGroupInfo &group) const;
269     void SetIsGroupOwner(bool isGroupOwner);
270     bool IsGroupOwner() const;
271     void SetOwner(const WifiP2pDevice &setOwner);
272     const WifiP2pDevice &GetOwner() const;
273     void SetPassphrase(const std::string &setPassphrase);
274     const std::string &GetPassphrase() const;
275     void SetInterface(const std::string &setInterface);
276     const std::string &GetInterface() const;
277     void SetGroupName(const std::string &newGroupName);
278     const std::string &GetGroupName() const;
279     void SetFrequency(int setFrequency);
280     int GetFrequency() const;
281     void SetIsPersistent(bool isPersistent);
282     bool IsPersistent() const;
283     void SetP2pGroupStatus(P2pGroupStatus newGroupStatus);
284     P2pGroupStatus GetP2pGroupStatus() const;
285     void SetNetworkId(int nwId);
286     const int &GetNetworkId() const;
287     void SetGoIpAddress(const std::string &ipAddr);
288     const std::string &GetGoIpAddress() const;
289     void SetGcIpAddress(const std::string &ipAddr);
290     const std::string &GetGcIpAddress() const;
291     void AddClientDevice(const WifiP2pDevice &clientDevice);
292     void AddPersistentDevice(const WifiP2pDevice &clientDevice);
293     void RemoveClientDevice(const WifiP2pDevice &clientDevice);
294     void RemovePersistentDevice(const WifiP2pDevice &clientDevice);
295     bool IsContainsDevice(const WifiP2pDevice &clientDevice) const;
296     bool IsContainsPersistentDevice(const WifiP2pDevice &clientDevice) const;
297     bool IsClientDevicesEmpty() const;
298     const std::vector<WifiP2pDevice> &GetClientDevices() const;
299     const std::vector<WifiP2pDevice> &GetPersistentDevices() const;
300     void SetClientDevices(const std::vector<WifiP2pDevice> &devices);
301     void SetClientPersistentDevices(const std::vector<WifiP2pDevice> &devices);
302     void ClearClientDevices();
303     bool IsExplicitGroup(void) const;
304     void SetExplicitGroup(bool isExplicit);
305     void SetCreatorUid(int uid);
306     int GetCreatorUid();
307     void SetPersistentFlag(bool flag);
308     bool GetPersistentFlag(void);
309 
310 private:
311     WifiP2pDevice owner;
312     bool isP2pGroupOwner;
313     std::string passphrase; /* the value ranges from 8 to 63. */
314     std::string interface;
315     std::string groupName;
316     int networkId;
317     int frequency; /* for example : freq=2412 to select 2.4 GHz channel 1.(Based on 2.4 GHz or 5 GHz) */
318     bool isP2pPersistent;
319     P2pGroupStatus groupStatus;
320     std::vector<WifiP2pDevice> clientDevices;
321     std::vector<WifiP2pDevice> persistentClients;
322     std::string goIpAddress;
323     std::string gcIpAddress;
324     bool explicitGroup;
325     int creatorUid = -1;
326     bool isOldPersistenGroup = false;
327 };
328 
329 class WpsInfo {
330 public:
WpsInfo()331     WpsInfo() : mWpsMethod(WpsMethod::WPS_METHOD_INVALID), bssid(""), pin("")
332     {}
~WpsInfo()333     ~WpsInfo()
334     {}
335     void SetWpsMethod(WpsMethod wpsMethod);
336     WpsMethod GetWpsMethod() const;
337 
338     void SetBssid(const std::string &setBssid);
339     const std::string &GetBssid() const;
340     void SetPin(const std::string &setPin);
341     const std::string &GetPin() const;
342 
343 private:
344     WpsMethod mWpsMethod;
345     std::string bssid; /* the length is 17 characters. */
346     std::string pin; /* the length is 4 or 8 characters. */
347 };
348 
349 const int AUTO_GROUP_OWNER_VALUE = -1;
350 const int MIN_GROUP_OWNER_VALUE = 0;
351 const int MAX_GROUP_OWNER_VALUE = 15;
352 class WifiP2pConfig {
353 public:
WifiP2pConfig()354     WifiP2pConfig()
355         : mDeviceAddress(""),
356           deviceAddressType(REAL_DEVICE_ADDRESS),
357           goBand(GroupOwnerBand::GO_BAND_AUTO),
358           netId(-1),
359           passphrase(""),
360           groupOwnerIntent(AUTO_GROUP_OWNER_VALUE),
361           groupName("")
362     {}
WifiP2pConfig(const WifiP2pConfig & config)363     WifiP2pConfig(const WifiP2pConfig &config)
364         : mDeviceAddress(config.GetDeviceAddress()),
365           deviceAddressType(config.GetDeviceAddressType()),
366           goBand(config.GetGoBand()),
367           netId(config.GetNetId()),
368           passphrase(config.GetPassphrase()),
369           groupOwnerIntent(config.GetGroupOwnerIntent()),
370           groupName(config.GetGroupName())
371     {}
~WifiP2pConfig()372     ~WifiP2pConfig()
373     {}
374     void SetDeviceAddress(const std::string &deviceAddress);
375     const std::string &GetDeviceAddress() const;
376     void SetDeviceAddressType(int addressAddrType);
377     int GetDeviceAddressType() const;
378     void SetGoBand(GroupOwnerBand setGoBand);
379     GroupOwnerBand GetGoBand() const;
380     void SetNetId(int setNetId);
381     int GetNetId() const;
382     void SetPassphrase(const std::string &newPassphrase);
383     const std::string &GetPassphrase() const;
384     void SetGroupOwnerIntent(int goIntent);
385     int GetGroupOwnerIntent() const;
386     void SetGroupName(const std::string &setGroupName);
387     const std::string &GetGroupName() const;
388 
389 private:
390     std::string mDeviceAddress; /* the device MAC address, the length is 17 characters. */
391     int deviceAddressType; /* the device MAC address type */
392     GroupOwnerBand goBand;
393     int netId; /* network id, when -2 means persistent and -1 means temporary, else need >= 0 */
394     std::string passphrase; /* the value ranges from 8 to 63. */
395     int groupOwnerIntent; /* the value is -1.(A value of -1 indicates the system can choose an appropriate value.) */
396     std::string groupName; /* the value ranges from 1 to 32. */
397 };
398 
399 class WifiP2pConfigInternal : public WifiP2pConfig {
400 public:
WifiP2pConfigInternal()401     WifiP2pConfigInternal(): WifiP2pConfig()
402     {
403         wpsInfo.SetWpsMethod(WpsMethod::WPS_METHOD_INVALID);
404     }
WifiP2pConfigInternal(WifiP2pConfig config)405     explicit WifiP2pConfigInternal(WifiP2pConfig config): WifiP2pConfig(config)
406     {
407         wpsInfo.SetWpsMethod(WpsMethod::WPS_METHOD_INVALID);
408     }
~WifiP2pConfigInternal()409     ~WifiP2pConfigInternal()
410     {}
SetWpsInfo(const WpsInfo & info)411     inline void SetWpsInfo(const WpsInfo &info)
412     {
413         wpsInfo = info;
414     }
GetWpsInfo()415     inline const WpsInfo &GetWpsInfo() const
416     {
417         return wpsInfo;
418     }
419 
420 private:
421     WpsInfo wpsInfo;
422 };
423 
424 class WifiP2pLinkedInfo {
425 public:
WifiP2pLinkedInfo()426     WifiP2pLinkedInfo() : connectState(P2pConnectedState::P2P_DISCONNECTED), isP2pGroupOwner(false)
427     {}
~WifiP2pLinkedInfo()428     ~WifiP2pLinkedInfo()
429     {}
430     void SetConnectState(P2pConnectedState setConnectState);
431     P2pConnectedState GetConnectState() const;
432     void SetIsGroupOwner(bool isGroupOwner);
433     const bool &IsGroupOwner() const;
434     void SetIsGroupOwnerAddress(const std::string &setGroupOwnerAddress);
435     const std::string &GetGroupOwnerAddress() const;
436     void AddClientInfoList(const std::string &mac, const std::string &ip, const std::string &host);
437     void RemoveClientInfo(std::string mac);
438     void ClearClientInfo();
439     const std::vector<GcInfo> &GetClientInfoList() const;
440 private:
441     P2pConnectedState connectState;
442     bool isP2pGroupOwner;
443     std::string groupOwnerAddress; /* the length is 17 characters. */
444     std::vector<GcInfo> gc_info_list;
445 };
446 
447 const int SERVICE_TLV_LENGTH_SIZE = 2;
448 const int PROTOCOL_SIZE = 1;
449 const int TRANSACTION_ID_SIZE = 1;
450 const int SERVICE_STATUS_SIZE = 1;
451 
452 class WifiP2pServiceRequest {
453 public:
WifiP2pServiceRequest()454     WifiP2pServiceRequest() : mProtocolType(P2pServicerProtocolType::SERVICE_TYPE_ALL), mTransactionId(0)
455     {}
WifiP2pServiceRequest(P2pServicerProtocolType protocolType,const std::string & data)456     WifiP2pServiceRequest(P2pServicerProtocolType protocolType, const std::string &data)
457         : mProtocolType(protocolType),
458           mTransactionId(0)
459     {
460         for (unsigned long i = 0; i < data.length(); ++i) {
461             mQuery.push_back(data.at(i));
462         }
463     }
~WifiP2pServiceRequest()464     ~WifiP2pServiceRequest()
465     {}
466     void SetProtocolType(P2pServicerProtocolType serviceProtocolType);
467     P2pServicerProtocolType GetProtocolType() const;
468     void SetTransactionId(unsigned char transactionId);
469     int GetTransactionId() const;
470     void SetQuery(const std::vector<unsigned char> &query);
471     const std::vector<unsigned char> &GetQuery() const;
472 
473     std::vector<unsigned char> GetTlv() const;
474 
475     bool operator==(const WifiP2pServiceRequest &cmp) const;
476 
477 private:
478     P2pServicerProtocolType mProtocolType;
479     unsigned char mTransactionId;
480     std::vector<unsigned char> mQuery;
481 };
482 
483 class WifiP2pServiceResponse {
484 public:
WifiP2pServiceResponse()485     WifiP2pServiceResponse()
486         : mProtocolType(P2pServicerProtocolType::SERVICE_TYPE_ALL),
487           mTransactionId(0),
488           mServiceStatus(P2pServiceStatus::PSRS_BAD_REQUEST)
489     {}
WifiP2pServiceResponse(P2pServicerProtocolType protocolType,P2pServiceStatus serviceStatus,unsigned char transactionId,const std::vector<unsigned char> data)490     WifiP2pServiceResponse(P2pServicerProtocolType protocolType, P2pServiceStatus serviceStatus,
491         unsigned char transactionId, const std::vector<unsigned char> data)
492         : mProtocolType(protocolType), mTransactionId(transactionId), mServiceStatus(serviceStatus), responseData(data)
493     {}
~WifiP2pServiceResponse()494     ~WifiP2pServiceResponse()
495     {}
496     void SetProtocolType(P2pServicerProtocolType serviceProtocolType);
497     P2pServicerProtocolType GetProtocolType() const;
498     void SetTransactionId(unsigned char transactionId);
499     unsigned char GetTransactionId() const;
500     void SetServiceStatus(P2pServiceStatus serviceStatus);
501     P2pServiceStatus GetServiceStatus() const;
502     void SetServiceName(const std::string &name);
503     const std::string &GetServiceName() const;
504     void SetData(const std::vector<unsigned char> &data);
505     const std::vector<unsigned char> &GetData() const;
506     std::vector<unsigned char> GetTlv() const;
507     bool operator==(const WifiP2pServiceResponse &cmp) const;
508 
509 protected:
510     P2pServicerProtocolType mProtocolType;
511     unsigned char mTransactionId;
512     P2pServiceStatus mServiceStatus;
513     std::string mSvrName;
514     std::vector<unsigned char> responseData;
515 };
516 
517 class WifiP2pServiceInfo {
518 public:
WifiP2pServiceInfo()519     WifiP2pServiceInfo()
520         : mDeviceAddress("00:00:00:00:00:00"), mProtocolType(P2pServicerProtocolType::SERVICE_TYPE_VENDOR_SPECIFIC)
521     {}
WifiP2pServiceInfo(std::vector<std::string> queryList)522     explicit WifiP2pServiceInfo(std::vector<std::string> queryList)
523         : mProtocolType(P2pServicerProtocolType::SERVICE_TYPE_VENDOR_SPECIFIC),
524           mQueryList(queryList)
525     {}
~WifiP2pServiceInfo()526     ~WifiP2pServiceInfo()
527     {}
528     void SetServiceName(const std::string &name);
529     const std::string &GetServiceName() const;
530     void SetDeviceAddress(const std::string &deviceAddress);
531     const std::string &GetDeviceAddress() const;
532     void SetServicerProtocolType(P2pServicerProtocolType type);
533     P2pServicerProtocolType GetServicerProtocolType() const;
534     void SetQueryList(const std::vector<std::string> &queryList);
535     const std::vector<std::string> &GetQueryList() const;
536     bool operator==(const WifiP2pServiceInfo &cmp) const;
537     /**
538      * @Description - Pack all data into a P2P service request packet based on the data interface.
539      * @return - WifiP2pServiceRequest
540      */
541     WifiP2pServiceRequest BuildRequest();
542     P2pServiceStatus ProcessServiceRequest(
543         const std::vector<unsigned char> &Query, std::vector<unsigned char> &data) const;
544     void ProcessServiceResponse(const std::vector<unsigned char> &data) const;
545     static std::string Bin2HexStr(std::vector<unsigned char> data);
546     static std::string Bin2HexStr(std::string data);
547 
548 private:
549     std::string serviceName;
550     std::string mDeviceAddress;
551     P2pServicerProtocolType mProtocolType;
552     std::vector<std::string> mQueryList;
553 };
554 
555 class P2pVendorConfig {
556 public:
P2pVendorConfig()557     P2pVendorConfig() : randomMacSupport(false), isAutoListen(false), primaryDeviceType("10-0050F204-5")
558     {}
~P2pVendorConfig()559     ~P2pVendorConfig()
560     {}
561     bool GetRandomMacSupport() const;
562     void SetRandomMacSupport(bool support);
563     bool GetIsAutoListen() const;
564     void SetIsAutoListen(bool autoListen);
565     const std::string &GetDeviceName() const;
566     void SetDeviceName(const std::string &name);
567     const std::string &GetPrimaryDeviceType() const;
568     void SetPrimaryDeviceType(const std::string &setPrimaryDeviceType);
569     const std::string &GetSecondaryDeviceType() const;
570     void SetSecondaryDeviceType(const std::string &setSecondaryDeviceType);
571 
572 private:
573     bool randomMacSupport;
574     bool isAutoListen;
575     std::string deviceName;
576     std::string primaryDeviceType;
577     std::string secondaryDeviceType;
578 };
579 }  // namespace Wifi
580 }  // namespace OHOS
581 #endif
582