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 AUTH_TCP_CONNECTION_STRUCT_H 17 #define AUTH_TCP_CONNECTION_STRUCT_H 18 19 #include <stdint.h> 20 #include <stdbool.h> 21 #include "auth_common_struct.h" 22 #include "softbus_conn_interface_struct.h" 23 #ifdef __cplusplus 24 #if __cplusplus 25 extern "C" { 26 #endif 27 #endif 28 29 #define AUTH_INVALID_FD (-1) 30 #define TCP_KEEPALIVE_INTERVAL 2 31 #define TCP_KEEPALIVE_HIGH_COUNT 3 32 #define TCP_KEEPALIVE_MID_COUNT 3 33 #define TCP_KEEPALIVE_LOW_COUNT 5 34 #define TCP_KEEPALIVE_DEFAULT_COUNT 5 35 #define TCP_KEEPALIVE_HIGH_USER_TIMEOUT (10 * 1000) 36 #define TCP_KEEPALIVE_MID_USER_TIMEOUT (10 * 1000) 37 #define TCP_KEEPALIVE_LOW_USER_TIMEOUT (15 * 1000) 38 #define TCP_KEEPALIVE_DEFAULT_USER_TIMEOUT (15 * 1000) 39 40 typedef struct { 41 void (*onConnected)(ListenerModule module, int32_t fd, bool isClient); 42 void (*onDisconnected)(ListenerModule module, int32_t fd); 43 void (*onDataReceived)(ListenerModule module, int32_t fd, const AuthDataHead *head, const uint8_t *data); 44 } SocketCallback; 45 46 #ifdef __cplusplus 47 #if __cplusplus 48 } 49 #endif 50 #endif 51 #endif /* AUTH_TCP_CONNECTION_STRUCT_H */