1e9297d28Sopenharmony_ci/* 2e9297d28Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 3e9297d28Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4e9297d28Sopenharmony_ci * you may not use this file except in compliance with the License. 5e9297d28Sopenharmony_ci * You may obtain a copy of the License at 6e9297d28Sopenharmony_ci * 7e9297d28Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8e9297d28Sopenharmony_ci * 9e9297d28Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10e9297d28Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11e9297d28Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e9297d28Sopenharmony_ci * See the License for the specific language governing permissions and 13e9297d28Sopenharmony_ci * limitations under the License. 14e9297d28Sopenharmony_ci */ 15e9297d28Sopenharmony_ci 16e9297d28Sopenharmony_ci#ifndef LOCAL_SOCAKT_PAIR_H 17e9297d28Sopenharmony_ci#define LOCAL_SOCAKT_PAIR_H 18e9297d28Sopenharmony_ci 19e9297d28Sopenharmony_ci#include <sys/types.h> 20e9297d28Sopenharmony_ci#include <refbase.h> 21e9297d28Sopenharmony_ci#include "message_parcel.h" 22e9297d28Sopenharmony_ci 23e9297d28Sopenharmony_cinamespace OHOS { 24e9297d28Sopenharmony_ciclass LocalSocketPair : public RefBase { 25e9297d28Sopenharmony_cipublic: 26e9297d28Sopenharmony_ci LocalSocketPair(); 27e9297d28Sopenharmony_ci virtual ~LocalSocketPair(); 28e9297d28Sopenharmony_ci LocalSocketPair(const LocalSocketPair &) = delete; 29e9297d28Sopenharmony_ci LocalSocketPair &operator=(const LocalSocketPair &) = delete; 30e9297d28Sopenharmony_ci int32_t CreateChannel(size_t sendSize, size_t receiveSize); 31e9297d28Sopenharmony_ci int32_t GetSendDataFd() const 32e9297d28Sopenharmony_ci { 33e9297d28Sopenharmony_ci return sendFd_; 34e9297d28Sopenharmony_ci }; 35e9297d28Sopenharmony_ci int32_t GetReceiveDataFd() const 36e9297d28Sopenharmony_ci { 37e9297d28Sopenharmony_ci return receiveFd_; 38e9297d28Sopenharmony_ci }; 39e9297d28Sopenharmony_ci 40e9297d28Sopenharmony_ci // send sendfd to binder 41e9297d28Sopenharmony_ci int32_t SendToBinder(MessageParcel &data); 42e9297d28Sopenharmony_ci 43e9297d28Sopenharmony_ci // send receivefd to binder 44e9297d28Sopenharmony_ci int32_t ReceiveToBinder(MessageParcel &data); 45e9297d28Sopenharmony_ci 46e9297d28Sopenharmony_ci int32_t SendData(const void *vaddr, size_t size); 47e9297d28Sopenharmony_ci int32_t ReceiveData(void *vaddr, size_t size); 48e9297d28Sopenharmony_ciprivate: 49e9297d28Sopenharmony_ci int32_t SendFdToBinder(MessageParcel &data, int32_t &fd); 50e9297d28Sopenharmony_ci void CloseFd(int32_t &fd); 51e9297d28Sopenharmony_ci int32_t SetSockopt(size_t sendSize, size_t receiveSize, int32_t* socketPair, int32_t socketPairSize); 52e9297d28Sopenharmony_ci 53e9297d28Sopenharmony_ciprivate: 54e9297d28Sopenharmony_ci int32_t sendFd_; 55e9297d28Sopenharmony_ci int32_t receiveFd_; 56e9297d28Sopenharmony_ci}; 57e9297d28Sopenharmony_ci} 58e9297d28Sopenharmony_ci 59e9297d28Sopenharmony_ci#endif // BS_LOCAL_SOCAKTPAIR_H 60