• 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_SOCKET_EXEC_H
17 #define COMMUNICATIONNETSTACK_SOCKET_EXEC_H
18 
19 #include "bind_context.h"
20 #include "common_context.h"
21 #include "connect_context.h"
22 #include "tcp_extra_context.h"
23 #include "tcp_send_context.h"
24 #include "udp_extra_context.h"
25 #include "udp_send_context.h"
26 
27 namespace OHOS::NetStack::SocketExec {
28 int MakeTcpSocket(sa_family_t family);
29 
30 int MakeUdpSocket(sa_family_t family);
31 
32 /* async work execute */
33 bool ExecUdpBind(BindContext *context);
34 
35 bool ExecUdpSend(UdpSendContext *context);
36 
37 bool ExecTcpBind(BindContext *context);
38 
39 bool ExecConnect(ConnectContext *context);
40 
41 bool ExecTcpSend(TcpSendContext *context);
42 
43 bool ExecClose(CloseContext *context);
44 
45 bool ExecGetState(GetStateContext *context);
46 
47 bool ExecGetRemoteAddress(GetRemoteAddressContext *context);
48 
49 bool ExecTcpSetExtraOptions(TcpSetExtraOptionsContext *context);
50 
51 bool ExecUdpSetExtraOptions(UdpSetExtraOptionsContext *context);
52 
53 /* async work callback */
54 napi_value BindCallback(BindContext *context);
55 
56 napi_value UdpSendCallback(UdpSendContext *context);
57 
58 napi_value ConnectCallback(ConnectContext *context);
59 
60 napi_value TcpSendCallback(TcpSendContext *context);
61 
62 napi_value CloseCallback(CloseContext *context);
63 
64 napi_value GetStateCallback(GetStateContext *context);
65 
66 napi_value GetRemoteAddressCallback(GetRemoteAddressContext *context);
67 
68 napi_value TcpSetExtraOptionsCallback(TcpSetExtraOptionsContext *context);
69 
70 napi_value UdpSetExtraOptionsCallback(UdpSetExtraOptionsContext *context);
71 } // namespace OHOS::NetStack::SocketExec
72 
73 #endif /* COMMUNICATIONNETSTACK_SOCKET_EXEC_H */
74