1 /* 2 * Copyright (c) 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 TLS_TLSSOCKET_EXEC_H 17 #define TLS_TLSSOCKET_EXEC_H 18 19 #include <napi/native_api.h> 20 21 #include "common_context.h" 22 #include "tls_send_context.h" 23 #include "tls_bind_context.h" 24 #include "tls_extra_context.h" 25 #include "tls_napi_context.h" 26 #include "tls_connect_context.h" 27 #include "tls_init_context.h" 28 29 namespace OHOS { 30 namespace NetStack { 31 namespace TlsSocket { 32 class TLSSocketExec final { 33 public: 34 TLSSocketExec() = delete; 35 ~TLSSocketExec() = delete; 36 37 static bool ExecInit(TLSInitContext *context); 38 static bool ExecGetCertificate(GetCertificateContext *context); 39 static bool ExecConnect(TLSConnectContext *context); 40 static bool ExecGetCipherSuites(GetCipherSuitesContext *context); 41 static bool ExecGetRemoteCertificate(GetRemoteCertificateContext *context); 42 static bool ExecGetProtocol(GetProtocolContext *context); 43 static bool ExecGetSignatureAlgorithms(GetSignatureAlgorithmsContext *context); 44 static bool ExecSend(TLSSendContext *context); 45 static bool ExecClose(TLSNapiContext *context); 46 static bool ExecBind(TLSBindContext *context); 47 static bool ExecGetState(TLSGetStateContext *context); 48 static bool ExecGetRemoteAddress(TLSGetRemoteAddressContext *context); 49 static bool ExecGetLocalAddress(TLSGetLocalAddressContext *context); 50 static bool ExecSetExtraOptions(TLSSetExtraOptionsContext *context); 51 52 static napi_value GetCertificateCallback(GetCertificateContext *context); 53 static napi_value ConnectCallback(TLSConnectContext *context); 54 static napi_value GetCipherSuitesCallback(GetCipherSuitesContext *context); 55 static napi_value GetRemoteCertificateCallback(GetRemoteCertificateContext *context); 56 static napi_value GetProtocolCallback(GetProtocolContext *context); 57 static napi_value GetSignatureAlgorithmsCallback(GetSignatureAlgorithmsContext *context); 58 static napi_value SendCallback(TLSSendContext *context); 59 static napi_value CloseCallback(TLSNapiContext *context); 60 static napi_value BindCallback(TLSBindContext *context); 61 static napi_value GetStateCallback(TLSGetStateContext *context); 62 static napi_value GetRemoteAddressCallback(TLSGetRemoteAddressContext *context); 63 static napi_value GetLocalAddressCallback(TLSGetLocalAddressContext *context); 64 static napi_value SetExtraOptionsCallback(TLSSetExtraOptionsContext *context); 65 }; 66 } // namespace TlsSocket 67 } // namespace NetStack 68 } // namespace OHOS 69 #endif // TLS_TLSSOCKET_EXEC_H 70