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