• 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 #ifndef COMMUNICATIONNETSTACK_TCP_EXTRA_OPTIONS_H
17 #define COMMUNICATIONNETSTACK_TCP_EXTRA_OPTIONS_H
18 
19 #include <cstdint>
20 
21 #include "extra_options_base.h"
22 
23 namespace OHOS::NetStack {
24 class TCPExtraOptions final : public ExtraOptionsBase {
25 private:
26     class SocketLinger {
27     public:
28         SocketLinger();
29 
30         ~SocketLinger() = default;
31 
32         void SetOn(bool on);
33 
34         void SetLinger(uint32_t linger);
35 
36         [[nodiscard]] bool IsOn() const;
37 
38         [[nodiscard]] uint32_t GetLinger() const;
39 
40     private:
41         bool on_;
42         uint32_t linger_;
43     };
44 
45 public:
46     TCPExtraOptions();
47 
48     ~TCPExtraOptions() = default;
49 
50     void SetKeepAlive(bool keepAlive);
51 
52     void SetOOBInline(bool OOBInline);
53 
54     void SetTCPNoDelay(bool TCPNoDelay);
55 
56     [[nodiscard]] bool IsKeepAlive() const;
57 
58     [[nodiscard]] bool IsOOBInline() const;
59 
60     [[nodiscard]] bool IsTCPNoDelay() const;
61 
62     SocketLinger socketLinger;
63 
64 private:
65     bool keepAlive_;
66 
67     bool OOBInline_;
68 
69     bool TCPNoDelay_;
70 };
71 } // namespace OHOS::NetStack
72 
73 #endif /* COMMUNICATIONNETSTACK_TCP_EXTRA_OPTIONS_H */
74