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 SetChrErrCode(P2pChrEvent errCode); 232 P2pChrEvent GetChrErrCode() const; 233 void SetGroupAddress(const std::string &groupAddress); 234 const std::string &GetGroupAddress() 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 void SetPersistentFlag(bool flag); 309 bool GetPersistentFlag(void); 310 311 private: 312 WifiP2pDevice owner; 313 bool isP2pGroupOwner; 314 std::string passphrase; /* the value ranges from 8 to 63. */ 315 std::string interface; 316 std::string groupName; 317 int networkId; 318 int frequency; /* for example : freq=2412 to select 2.4 GHz channel 1.(Based on 2.4 GHz or 5 GHz) */ 319 bool isP2pPersistent; 320 P2pGroupStatus groupStatus; 321 std::vector<WifiP2pDevice> clientDevices; 322 std::vector<WifiP2pDevice> persistentClients; 323 std::string goIpAddress; 324 std::string gcIpAddress; 325 bool explicitGroup; 326 int creatorUid = -1; 327 bool isOldPersistenGroup = false; 328 }; 329 330 class WpsInfo { 331 public: WpsInfo()332 WpsInfo() : mWpsMethod(WpsMethod::WPS_METHOD_INVALID), bssid(""), pin("") 333 {} ~WpsInfo()334 ~WpsInfo() 335 {} 336 void SetWpsMethod(WpsMethod wpsMethod); 337 WpsMethod GetWpsMethod() const; 338 339 void SetBssid(const std::string &setBssid); 340 const std::string &GetBssid() const; 341 void SetPin(const std::string &setPin); 342 const std::string &GetPin() const; 343 344 private: 345 WpsMethod mWpsMethod; 346 std::string bssid; /* the length is 17 characters. */ 347 std::string pin; /* the length is 4 or 8 characters. */ 348 }; 349 350 inline const int AUTO_GROUP_OWNER_VALUE = -1; 351 inline const int MIN_GROUP_OWNER_VALUE = 0; 352 inline const int MAX_GROUP_OWNER_VALUE = 15; 353 class WifiP2pConfig { 354 public: WifiP2pConfig()355 WifiP2pConfig() 356 : mDeviceAddress(""), 357 deviceAddressType(REAL_DEVICE_ADDRESS), 358 goBand(GroupOwnerBand::GO_BAND_AUTO), 359 netId(-1), 360 passphrase(""), 361 groupOwnerIntent(AUTO_GROUP_OWNER_VALUE), 362 groupName("") 363 {} WifiP2pConfig(const WifiP2pConfig & config)364 WifiP2pConfig(const WifiP2pConfig &config) 365 : mDeviceAddress(config.GetDeviceAddress()), 366 deviceAddressType(config.GetDeviceAddressType()), 367 goBand(config.GetGoBand()), 368 netId(config.GetNetId()), 369 passphrase(config.GetPassphrase()), 370 groupOwnerIntent(config.GetGroupOwnerIntent()), 371 groupName(config.GetGroupName()) 372 {} ~WifiP2pConfig()373 ~WifiP2pConfig() 374 {} 375 void SetDeviceAddress(const std::string &deviceAddress); 376 const std::string &GetDeviceAddress() const; 377 void SetDeviceAddressType(int addressAddrType); 378 int GetDeviceAddressType() const; 379 void SetGoBand(GroupOwnerBand setGoBand); 380 GroupOwnerBand GetGoBand() const; 381 void SetNetId(int setNetId); 382 int GetNetId() const; 383 void SetPassphrase(const std::string &newPassphrase); 384 const std::string &GetPassphrase() const; 385 void SetGroupOwnerIntent(int goIntent); 386 int GetGroupOwnerIntent() const; 387 void SetGroupName(const std::string &setGroupName); 388 const std::string &GetGroupName() const; 389 390 private: 391 std::string mDeviceAddress; /* the device MAC address, the length is 17 characters. */ 392 int deviceAddressType; /* the device MAC address type */ 393 GroupOwnerBand goBand; 394 int netId; /* network id, when -2 means persistent and -1 means temporary, else need >= 0 */ 395 std::string passphrase; /* the value ranges from 8 to 63. */ 396 int groupOwnerIntent; /* the value is -1.(A value of -1 indicates the system can choose an appropriate value.) */ 397 std::string groupName; /* the value ranges from 1 to 32. */ 398 }; 399 400 class WifiP2pConfigInternal : public WifiP2pConfig { 401 public: WifiP2pConfigInternal()402 WifiP2pConfigInternal(): WifiP2pConfig() 403 { 404 wpsInfo.SetWpsMethod(WpsMethod::WPS_METHOD_INVALID); 405 } WifiP2pConfigInternal(WifiP2pConfig config)406 explicit WifiP2pConfigInternal(WifiP2pConfig config): WifiP2pConfig(config) 407 { 408 wpsInfo.SetWpsMethod(WpsMethod::WPS_METHOD_INVALID); 409 } ~WifiP2pConfigInternal()410 ~WifiP2pConfigInternal() 411 {} SetWpsInfo(const WpsInfo & info)412 inline void SetWpsInfo(const WpsInfo &info) 413 { 414 wpsInfo = info; 415 } GetWpsInfo()416 inline const WpsInfo &GetWpsInfo() const 417 { 418 return wpsInfo; 419 } 420 421 private: 422 WpsInfo wpsInfo; 423 }; 424 425 class WifiP2pLinkedInfo { 426 public: WifiP2pLinkedInfo()427 WifiP2pLinkedInfo() : connectState(P2pConnectedState::P2P_DISCONNECTED), isP2pGroupOwner(false) 428 {} ~WifiP2pLinkedInfo()429 ~WifiP2pLinkedInfo() 430 {} 431 void SetConnectState(P2pConnectedState setConnectState); 432 P2pConnectedState GetConnectState() const; 433 void SetIsGroupOwner(bool isGroupOwner); 434 const bool &IsGroupOwner() const; 435 void SetIsGroupOwnerAddress(const std::string &setGroupOwnerAddress); 436 const std::string &GetGroupOwnerAddress() const; 437 void AddClientInfoList(const std::string &mac, const std::string &ip, const std::string &host); 438 void RemoveClientInfo(std::string mac); 439 void ClearClientInfo(); 440 const std::vector<GcInfo> &GetClientInfoList() const; 441 private: 442 P2pConnectedState connectState; 443 bool isP2pGroupOwner; 444 std::string groupOwnerAddress; /* the length is 17 characters. */ 445 std::vector<GcInfo> gc_info_list; 446 }; 447 448 inline const int SERVICE_TLV_LENGTH_SIZE = 2; 449 inline const int PROTOCOL_SIZE = 1; 450 inline const int TRANSACTION_ID_SIZE = 1; 451 const int SERVICE_STATUS_SIZE = 1; 452 453 class WifiP2pServiceRequest { 454 public: WifiP2pServiceRequest()455 WifiP2pServiceRequest() : mProtocolType(P2pServicerProtocolType::SERVICE_TYPE_ALL), mTransactionId(0) 456 {} WifiP2pServiceRequest(P2pServicerProtocolType protocolType,const std::string & data)457 WifiP2pServiceRequest(P2pServicerProtocolType protocolType, const std::string &data) 458 : mProtocolType(protocolType), 459 mTransactionId(0) 460 { 461 for (unsigned long i = 0; i < data.length(); ++i) { 462 mQuery.push_back(data.at(i)); 463 } 464 } ~WifiP2pServiceRequest()465 ~WifiP2pServiceRequest() 466 {} 467 void SetProtocolType(P2pServicerProtocolType serviceProtocolType); 468 P2pServicerProtocolType GetProtocolType() const; 469 void SetTransactionId(unsigned char transactionId); 470 int GetTransactionId() const; 471 void SetQuery(const std::vector<unsigned char> &query); 472 const std::vector<unsigned char> &GetQuery() const; 473 474 std::vector<unsigned char> GetTlv() const; 475 476 bool operator==(const WifiP2pServiceRequest &cmp) const; 477 478 private: 479 P2pServicerProtocolType mProtocolType; 480 unsigned char mTransactionId; 481 std::vector<unsigned char> mQuery; 482 }; 483 484 class WifiP2pServiceResponse { 485 public: WifiP2pServiceResponse()486 WifiP2pServiceResponse() 487 : mProtocolType(P2pServicerProtocolType::SERVICE_TYPE_ALL), 488 mTransactionId(0), 489 mServiceStatus(P2pServiceStatus::PSRS_BAD_REQUEST) 490 {} WifiP2pServiceResponse(P2pServicerProtocolType protocolType,P2pServiceStatus serviceStatus,unsigned char transactionId,const std::vector<unsigned char> data)491 WifiP2pServiceResponse(P2pServicerProtocolType protocolType, P2pServiceStatus serviceStatus, 492 unsigned char transactionId, const std::vector<unsigned char> data) 493 : mProtocolType(protocolType), mTransactionId(transactionId), mServiceStatus(serviceStatus), responseData(data) 494 {} ~WifiP2pServiceResponse()495 ~WifiP2pServiceResponse() 496 {} 497 void SetProtocolType(P2pServicerProtocolType serviceProtocolType); 498 P2pServicerProtocolType GetProtocolType() const; 499 void SetTransactionId(unsigned char transactionId); 500 unsigned char GetTransactionId() const; 501 void SetServiceStatus(P2pServiceStatus serviceStatus); 502 P2pServiceStatus GetServiceStatus() const; 503 void SetServiceName(const std::string &name); 504 const std::string &GetServiceName() const; 505 void SetData(const std::vector<unsigned char> &data); 506 const std::vector<unsigned char> &GetData() const; 507 std::vector<unsigned char> GetTlv() const; 508 bool operator==(const WifiP2pServiceResponse &cmp) const; 509 510 protected: 511 P2pServicerProtocolType mProtocolType; 512 unsigned char mTransactionId; 513 P2pServiceStatus mServiceStatus; 514 std::string mSvrName; 515 std::vector<unsigned char> responseData; 516 }; 517 518 class WifiP2pServiceInfo { 519 public: WifiP2pServiceInfo()520 WifiP2pServiceInfo() 521 : mDeviceAddress("00:00:00:00:00:00"), mProtocolType(P2pServicerProtocolType::SERVICE_TYPE_VENDOR_SPECIFIC) 522 {} WifiP2pServiceInfo(std::vector<std::string> queryList)523 explicit WifiP2pServiceInfo(std::vector<std::string> queryList) 524 : mProtocolType(P2pServicerProtocolType::SERVICE_TYPE_VENDOR_SPECIFIC), 525 mQueryList(queryList) 526 {} ~WifiP2pServiceInfo()527 ~WifiP2pServiceInfo() 528 {} 529 void SetServiceName(const std::string &name); 530 const std::string &GetServiceName() const; 531 void SetDeviceAddress(const std::string &deviceAddress); 532 const std::string &GetDeviceAddress() const; 533 void SetServicerProtocolType(P2pServicerProtocolType type); 534 P2pServicerProtocolType GetServicerProtocolType() const; 535 void SetQueryList(const std::vector<std::string> &queryList); 536 const std::vector<std::string> &GetQueryList() const; 537 bool operator==(const WifiP2pServiceInfo &cmp) const; 538 /** 539 * @Description - Pack all data into a P2P service request packet based on the data interface. 540 * @return - WifiP2pServiceRequest 541 */ 542 WifiP2pServiceRequest BuildRequest(); 543 P2pServiceStatus ProcessServiceRequest( 544 const std::vector<unsigned char> &Query, std::vector<unsigned char> &data) const; 545 void ProcessServiceResponse(const std::vector<unsigned char> &data) const; 546 static std::string Bin2HexStr(std::vector<unsigned char> data); 547 static std::string Bin2HexStr(std::string data); 548 549 private: 550 std::string serviceName; 551 std::string mDeviceAddress; 552 P2pServicerProtocolType mProtocolType; 553 std::vector<std::string> mQueryList; 554 }; 555 556 class P2pVendorConfig { 557 public: P2pVendorConfig()558 P2pVendorConfig() : randomMacSupport(false), isAutoListen(false), primaryDeviceType("10-0050F204-5") 559 {} ~P2pVendorConfig()560 ~P2pVendorConfig() 561 {} 562 bool GetRandomMacSupport() const; 563 void SetRandomMacSupport(bool support); 564 bool GetIsAutoListen() const; 565 void SetIsAutoListen(bool autoListen); 566 const std::string &GetDeviceName() const; 567 void SetDeviceName(const std::string &name); 568 const std::string &GetPrimaryDeviceType() const; 569 void SetPrimaryDeviceType(const std::string &setPrimaryDeviceType); 570 const std::string &GetSecondaryDeviceType() const; 571 void SetSecondaryDeviceType(const std::string &setSecondaryDeviceType); 572 573 private: 574 bool randomMacSupport; 575 bool isAutoListen; 576 std::string deviceName; 577 std::string primaryDeviceType; 578 std::string secondaryDeviceType; 579 }; 580 } // namespace Wifi 581 } // namespace OHOS 582 #endif 583