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