1 /* 2 * Copyright (c) 2025 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 NET_WEBSOCKET_FFI_STRUCTS_H 17 #define NET_WEBSOCKET_FFI_STRUCTS_H 18 19 #include <cstdint> 20 21 #include "cj_ffi/cj_common_ffi.h" 22 23 #ifdef __cplusplus 24 #define EXTERN_C_START extern "C" { 25 #define EXTERN_C_END } 26 #else 27 #define EXTERN_C_START 28 #define EXTERN_C_END 29 #endif 30 31 EXTERN_C_START 32 struct CHttpProxy { 33 char* host; 34 uint16_t port; 35 char** exclusionList; 36 int64_t exclusionListSize; 37 }; 38 39 struct CClientCert { 40 char* certPath; 41 char* keyPath; 42 char* keyPassword; 43 }; 44 45 struct CWebSocketRequestOptions { 46 CArrString header; 47 char* caPath; 48 CClientCert* clientCert; 49 char* protocol; 50 bool usingSystemProxy; 51 CHttpProxy* httpProxy; 52 uint32_t pingInterval; 53 uint32_t pongTimeout; 54 }; 55 56 struct CWebSocketCloseOptions { 57 uint32_t code; 58 char* reason; 59 }; 60 61 struct CWebSocketCallbackData { 62 int32_t code; 63 int32_t typeId; 64 uint8_t* data; 65 int32_t dataLen; 66 }; 67 68 struct COpenResponse { 69 uint32_t status; 70 char* message; 71 }; 72 73 struct CMessageResponse { 74 CArrUI8 result; 75 int32_t resultType; 76 }; 77 78 struct CErrorResponse { 79 int32_t code; 80 uint32_t httpResponse; 81 }; 82 83 struct CCloseResponse { 84 uint32_t code; 85 char* reason; 86 }; 87 88 struct CReceiveResponse { 89 CArrString header; 90 int32_t headerType; 91 }; 92 EXTERN_C_END 93 94 #endif