1 /* 2 * Copyright (c) 2021-2023 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 "tcp_server_common_context.h" 25 #include "tcp_server_extra_context.h" 26 #include "tcp_server_listen_context.h" 27 #include "tcp_server_send_context.h" 28 #include "udp_extra_context.h" 29 #include "udp_send_context.h" 30 31 namespace OHOS::NetStack::Socket::SocketExec { 32 int MakeTcpSocket(sa_family_t family); 33 34 int MakeUdpSocket(sa_family_t family); 35 36 /* async work execute */ 37 bool ExecUdpBind(BindContext *context); 38 39 bool ExecUdpSend(UdpSendContext *context); 40 41 bool ExecTcpBind(BindContext *context); 42 43 bool ExecConnect(ConnectContext *context); 44 45 bool ExecTcpSend(TcpSendContext *context); 46 47 bool ExecClose(CloseContext *context); 48 49 bool ExecGetState(GetStateContext *context); 50 51 bool ExecGetRemoteAddress(GetRemoteAddressContext *context); 52 53 bool ExecTcpSetExtraOptions(TcpSetExtraOptionsContext *context); 54 55 bool ExecUdpSetExtraOptions(UdpSetExtraOptionsContext *context); 56 57 bool ExecTcpGetSocketFd(GetSocketFdContext *context); 58 59 bool ExecUdpGetSocketFd(GetSocketFdContext *context); 60 61 bool ExecTcpConnectionSend(TcpServerSendContext *context); 62 63 bool ExecTcpConnectionGetRemoteAddress(TcpServerGetRemoteAddressContext *context); 64 65 bool ExecTcpConnectionClose(TcpServerCloseContext *context); 66 67 bool ExecTcpServerListen(TcpServerListenContext *context); 68 69 bool ExecTcpServerSetExtraOptions(TcpServerSetExtraOptionsContext *context); 70 71 bool ExecTcpServerGetState(TcpServerGetStateContext *context); 72 73 /* async work callback */ 74 napi_value BindCallback(BindContext *context); 75 76 napi_value UdpSendCallback(UdpSendContext *context); 77 78 napi_value ConnectCallback(ConnectContext *context); 79 80 napi_value TcpSendCallback(TcpSendContext *context); 81 82 napi_value CloseCallback(CloseContext *context); 83 84 napi_value GetStateCallback(GetStateContext *context); 85 86 napi_value GetRemoteAddressCallback(GetRemoteAddressContext *context); 87 88 napi_value TcpSetExtraOptionsCallback(TcpSetExtraOptionsContext *context); 89 90 napi_value UdpSetExtraOptionsCallback(UdpSetExtraOptionsContext *context); 91 92 napi_value TcpGetSocketFdCallback(GetSocketFdContext *context); 93 94 napi_value TcpConnectionSendCallback(TcpServerSendContext *context); 95 96 napi_value TcpConnectionCloseCallback(TcpServerCloseContext *context); 97 98 napi_value TcpConnectionGetRemoteAddressCallback(TcpServerGetRemoteAddressContext *context); 99 100 napi_value ListenCallback(TcpServerListenContext *context); 101 102 napi_value TcpServerSetExtraOptionsCallback(TcpServerSetExtraOptionsContext *context); 103 104 napi_value TcpServerGetStateCallback(TcpServerGetStateContext *context); 105 106 napi_value UdpGetSocketFdCallback(GetSocketFdContext *context); 107 } // namespace OHOS::NetStack::Socket::SocketExec 108 #endif /* COMMUNICATIONNETSTACK_SOCKET_EXEC_H */ 109