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 USB_REQUEST_H 17#define USB_REQUEST_H 18 19#include "iusb_srv.h" 20#include "usb_device_pipe.h" 21#include "usb_endpoint.h" 22 23namespace OHOS { 24namespace USB { 25class UsbRequest { 26public: 27 UsbRequest() {} 28 ~UsbRequest() {} 29 int32_t Initialize(const USBDevicePipe &pipe, const USBEndpoint &endpoint); 30 int32_t Queue(); 31 int32_t Free(); 32 int32_t Abort(); 33 void SetPipe(const USBDevicePipe &pipe) 34 { 35 this->pipe_ = pipe; 36 } 37 void SetEndpoint(const USBEndpoint &endpoint) 38 { 39 this->endpoint_ = endpoint; 40 } 41 void SetClientData(std::vector<uint8_t> bufferData) 42 { 43 clientData_ = bufferData; 44 } 45 void SetReqData(std::vector<uint8_t> bufferData) 46 { 47 reqData_ = bufferData; 48 } 49 std::vector<uint8_t> &GetClientData() 50 { 51 return clientData_; 52 } 53 std::vector<uint8_t> &GetReqData() 54 { 55 return reqData_; 56 } 57 const USBDevicePipe &GetPipe() const 58 { 59 return pipe_; 60 } 61 const USBEndpoint &GetEndpoint() const 62 { 63 return endpoint_; 64 } 65 66private: 67 USBDevicePipe pipe_; 68 USBEndpoint endpoint_; 69 std::vector<uint8_t> clientData_; 70 std::vector<uint8_t> reqData_; 71}; 72} // namespace USB 73} // namespace OHOS 74 75#endif // USB_REQUEST_H 76