1 /* 2 * Copyright (c) 2024 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 #ifndef WIFI_DIRECT_PROTOCOL_H 16 #define WIFI_DIRECT_PROTOCOL_H 17 18 #include <string> 19 #include <vector> 20 #include "data/serializable.h" 21 22 namespace OHOS::SoftBus { 23 struct ProtocolFormat { 24 uint32_t tagSize; 25 uint32_t lengthSize; 26 }; 27 28 enum class ProtocolType { 29 JSON, 30 TLV, 31 }; 32 33 class WifiDirectProtocol { 34 public: 35 virtual ProtocolType GetType() = 0; 36 virtual void SetFormat(const ProtocolFormat &format) = 0; 37 virtual ProtocolFormat GetFormat() const = 0; 38 39 virtual void Write(int key, Serializable::ValueType type, const uint8_t *value, size_t size) = 0; 40 virtual bool Read(int &key, uint8_t *&value, size_t &size) = 0; 41 42 virtual void SetInput(const std::vector<uint8_t> &input) = 0; 43 virtual void GetOutput(std::vector<uint8_t> &output) = 0; 44 45 virtual ~WifiDirectProtocol() = default; 46 }; 47 } 48 #endif 49