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 #include "extra_options_base.h" 17 18 namespace OHOS::NetStack::Socket { ExtraOptionsBase()19ExtraOptionsBase::ExtraOptionsBase() 20 : receiveBufferSize_(0), sendBufferSize_(0), reuseAddress_(false), socketTimeout_(0) 21 { 22 } 23 SetReceiveBufferSize(uint32_t receiveBufferSize)24void ExtraOptionsBase::SetReceiveBufferSize(uint32_t receiveBufferSize) 25 { 26 receiveBufferSize_ = receiveBufferSize; 27 } 28 SetSendBufferSize(uint32_t sendBufferSize)29void ExtraOptionsBase::SetSendBufferSize(uint32_t sendBufferSize) 30 { 31 sendBufferSize_ = sendBufferSize; 32 } 33 SetReuseAddress(bool reuseAddress)34void ExtraOptionsBase::SetReuseAddress(bool reuseAddress) 35 { 36 reuseAddress_ = reuseAddress; 37 } 38 SetSocketTimeout(uint32_t socketTimeout)39void ExtraOptionsBase::SetSocketTimeout(uint32_t socketTimeout) 40 { 41 socketTimeout_ = socketTimeout; 42 } 43 GetReceiveBufferSize() const44uint32_t ExtraOptionsBase::GetReceiveBufferSize() const 45 { 46 return receiveBufferSize_; 47 } 48 GetSendBufferSize() const49uint32_t ExtraOptionsBase::GetSendBufferSize() const 50 { 51 return sendBufferSize_; 52 } 53 IsReuseAddress() const54bool ExtraOptionsBase::IsReuseAddress() const 55 { 56 return reuseAddress_; 57 } 58 GetSocketTimeout() const59uint32_t ExtraOptionsBase::GetSocketTimeout() const 60 { 61 return socketTimeout_; 62 } 63 AlreadySetRecvBufSize() const64bool ExtraOptionsBase::AlreadySetRecvBufSize() const 65 { 66 return recvBufSizeFlag_; 67 } 68 SetRecvBufSizeFlag(bool flag)69void ExtraOptionsBase::SetRecvBufSizeFlag(bool flag) 70 { 71 recvBufSizeFlag_ = flag; 72 } 73 AlreadySetSendBufSize() const74bool ExtraOptionsBase::AlreadySetSendBufSize() const 75 { 76 return sendBufSizeFlag_; 77 } 78 SetSendBufSizeFlag(bool flag)79void ExtraOptionsBase::SetSendBufSizeFlag(bool flag) 80 { 81 sendBufSizeFlag_ = flag; 82 } 83 AlreadySetTimeout() const84bool ExtraOptionsBase::AlreadySetTimeout() const 85 { 86 return timeoutFlag_; 87 } 88 SetTimeoutFlag(bool flag)89void ExtraOptionsBase::SetTimeoutFlag(bool flag) 90 { 91 timeoutFlag_ = flag; 92 } 93 AlreadySetReuseAddr() const94bool ExtraOptionsBase::AlreadySetReuseAddr() const 95 { 96 return reuseAddrFlag_; 97 } 98 SetReuseaddrFlag(bool flag)99void ExtraOptionsBase::SetReuseaddrFlag(bool flag) 100 { 101 reuseAddrFlag_ = flag; 102 } 103 } // namespace OHOS::NetStack::Socket 104