1 /* 2 * Copyright (c) 2024 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_CONNECTION_FFI_H 17 #define NET_CONNECTION_FFI_H 18 19 #include "cj_ffi/cj_common_ffi.h" 20 #include "common.h" 21 #include "ffi_remote_data.h" 22 #include "netmanager_base_log.h" 23 #include <cstdint> 24 #include <list> 25 #include <set> 26 #include <vector> 27 28 EXTERN_C_START 29 FFI_EXPORT int64_t CJ_CreateNetConnection(CNetSpecifier netSpecifier, uint32_t timeout); 30 FFI_EXPORT void CJ_ReleaseNetConnection(int64_t connId); 31 FFI_EXPORT int32_t CJ_GetDefaultNet(int32_t &netId); 32 FFI_EXPORT RetNetAddressArr CJ_GetAddressesByName(int32_t netId, const char *host); 33 FFI_EXPORT int32_t CJ_IsDefaultNetMetered(bool &ret); 34 FFI_EXPORT int32_t CJ_HasDefaultNet(bool &ret); 35 FFI_EXPORT int32_t CJ_GetNetCapabilities(int32_t netId, CNetCapabilities &ret); 36 FFI_EXPORT int32_t CJ_GetConnectionProperties(int32_t netId, CConnectionProperties &ret); 37 FFI_EXPORT int32_t CJ_GetGlobalHttpProxy(CHttpProxy &chttpProxy); 38 FFI_EXPORT int32_t CJ_GetDefaultHttpProxy(CHttpProxy &chttpProxy); 39 FFI_EXPORT int32_t CJ_SetGlobalHttpProxy(CHttpProxy cHttpProxy); 40 FFI_EXPORT RetDataCArrI32 CJ_GetAllNets(); 41 FFI_EXPORT int32_t CJ_EnableAirplaneMode(); 42 FFI_EXPORT int32_t CJ_DisableAirplaneMode(); 43 FFI_EXPORT int32_t CJ_ReportNetConnected(int32_t netId); 44 FFI_EXPORT int32_t CJ_ReportNetDisconnected(int32_t netId); 45 FFI_EXPORT int32_t CJ_NetConnectionRegister(int64_t id); 46 FFI_EXPORT int32_t CJ_NetConnectionUnRegister(int64_t id); 47 FFI_EXPORT int32_t CJ_NetHandleBindSocket(int32_t netId, int socketFd); 48 FFI_EXPORT void CJ_OnNetAvailable(int64_t connId, void (*callback)(int32_t)); 49 FFI_EXPORT void CJ_OnNetBlockStatusChange(int64_t connId, void (*callback)(int32_t, bool)); 50 FFI_EXPORT void CJ_OnNetCapabilitiesChange(int64_t connId, void (*callback)(CNetCapabilityInfo)); 51 FFI_EXPORT void CJ_OnNetConnectionPropertiesChange(int64_t connId, void (*callback)(int32_t, CConnectionProperties)); 52 FFI_EXPORT void CJ_OnNetLost(int64_t connId, void (*callback)(int32_t)); 53 FFI_EXPORT void CJ_OnNetUnavailable(int64_t connId, void (*callback)()); 54 FFI_EXPORT int32_t CJ_GetAppNet(int32_t &netId); 55 FFI_EXPORT int32_t CJ_SetAppNet(int32_t netId); 56 57 char *MallocCString(const std::string &origin); 58 char **MallocCStringList(std::list<std::string> &list); 59 EXTERN_C_END 60 61 #endif