• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "tcp_extra_options.h"
17 
18 namespace OHOS::NetStack {
SocketLinger()19 TCPExtraOptions::SocketLinger::SocketLinger() : on_(false), linger_(0) {}
20 
SetOn(bool on)21 void TCPExtraOptions::SocketLinger::SetOn(bool on)
22 {
23     on_ = on;
24 }
25 
SetLinger(uint32_t linger)26 void TCPExtraOptions::SocketLinger::SetLinger(uint32_t linger)
27 {
28     linger_ = linger;
29 }
30 
IsOn() const31 bool TCPExtraOptions::SocketLinger::IsOn() const
32 {
33     return on_;
34 }
35 
GetLinger() const36 uint32_t TCPExtraOptions::SocketLinger::GetLinger() const
37 {
38     return linger_;
39 }
40 
TCPExtraOptions()41 TCPExtraOptions::TCPExtraOptions() : keepAlive_(false), OOBInline_(false), TCPNoDelay_(false) {}
42 
SetKeepAlive(bool keepAlive)43 void TCPExtraOptions::SetKeepAlive(bool keepAlive)
44 {
45     keepAlive_ = keepAlive;
46 }
47 
SetOOBInline(bool OOBInline)48 void TCPExtraOptions::SetOOBInline(bool OOBInline)
49 {
50     OOBInline_ = OOBInline;
51 }
52 
SetTCPNoDelay(bool TCPNoDelay)53 void TCPExtraOptions::SetTCPNoDelay(bool TCPNoDelay)
54 {
55     TCPNoDelay_ = TCPNoDelay;
56 }
57 
IsKeepAlive() const58 bool TCPExtraOptions::IsKeepAlive() const
59 {
60     return keepAlive_;
61 }
62 
IsOOBInline() const63 bool TCPExtraOptions::IsOOBInline() const
64 {
65     return OOBInline_;
66 }
67 
IsTCPNoDelay() const68 bool TCPExtraOptions::IsTCPNoDelay() const
69 {
70     return TCPNoDelay_;
71 }
72 } // namespace OHOS::NetStack