1 /* 2 * Copyright (c) 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 TLS_TLSSOCKETSERVER_EXEC_H 17 #define TLS_TLSSOCKETSERVER_EXEC_H 18 19 #include <napi/native_api.h> 20 21 #include "common_context.h" 22 #include "tls_bind_context.h" 23 #include "tls_connect_context.h" 24 #include "tls_extra_context.h" 25 #include "tls_napi_context.h" 26 #include "tls_server_close_context.h" 27 #include "tls_server_napi_context.h" 28 #include "tls_server_send_context.h" 29 30 namespace OHOS { 31 namespace NetStack { 32 namespace TlsSocketServer { 33 class TLSSocketServerExec final { 34 public: 35 TLSSocketServerExec() = delete; 36 ~TLSSocketServerExec() = delete; 37 38 static bool ExecGetCertificate(TlsSocket::GetCertificateContext *context); 39 static bool ExecListen(TlsSocket::TLSListenContext *context); 40 static bool ExecGetCipherSuites(ServerGetCipherSuitesContext *context); 41 static bool ExecGetRemoteCertificate(ServerGetRemoteCertificateContext *context); 42 static bool ExecGetProtocol(TlsSocket::GetProtocolContext *context); 43 static bool ExecGetSignatureAlgorithms(ServerGetSignatureAlgorithmsContext *context); 44 static bool ExecSend(TLSServerSendContext *context); 45 static bool ExecClose(TLSServerCloseContext *context); 46 static bool ExecStop(TlsSocket::TLSNapiContext *context); 47 static bool ExecGetState(TlsSocket::TLSGetStateContext *context); 48 static bool ExecGetRemoteAddress(ServerTLSGetRemoteAddressContext *context); 49 static bool ExecGetLocalAddress(TLSServerGetLocalAddressContext *context); 50 static bool ExecConnectionGetLocalAddress(TLSConnectionGetLocalAddressContext *context); 51 static bool ExecSetExtraOptions(TlsSocket::TLSSetExtraOptionsContext *context); 52 53 static napi_value GetCertificateCallback(TlsSocket::GetCertificateContext *context); 54 static napi_value ListenCallback(TlsSocket::TLSListenContext *context); 55 static napi_value GetCipherSuitesCallback(ServerGetCipherSuitesContext *context); 56 static napi_value GetRemoteCertificateCallback(ServerGetRemoteCertificateContext *context); 57 static napi_value GetProtocolCallback(TlsSocket::GetProtocolContext *context); 58 static napi_value GetSignatureAlgorithmsCallback(ServerGetSignatureAlgorithmsContext *context); 59 static napi_value SendCallback(TLSServerSendContext *context); 60 static napi_value CloseCallback(TLSServerCloseContext *context); 61 static napi_value StopCallback(TlsSocket::TLSNapiContext *context); 62 static napi_value GetStateCallback(TlsSocket::TLSGetStateContext *context); 63 static napi_value GetRemoteAddressCallback(ServerTLSGetRemoteAddressContext *context); 64 static napi_value GetLocalAddressCallback(TLSServerGetLocalAddressContext *context); 65 static napi_value GetConnectionLocalAddressCallback(TLSConnectionGetLocalAddressContext *context); 66 static napi_value SetExtraOptionsCallback(TlsSocket::TLSSetExtraOptionsContext *context); 67 68 static bool ExecConnectionSend(TLSServerSendContext *context); 69 static napi_value ConnectionSendCallback(TLSServerSendContext *context); 70 }; 71 } // namespace TlsSocketServer 72 } // namespace NetStack 73 } // namespace OHOS 74 #endif // TLS_TLSSOCKETSERVER_EXEC_H 75