1 /* 2 * Copyright (c) 2021-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 DFX_FAULTLOGGERD_SOCKET_H 17 #define DFX_FAULTLOGGERD_SOCKET_H 18 19 #include <cinttypes> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 const char* const FAULTLOGGERD_SOCK_BASE_PATH = "/dev/unix/socket/"; 25 26 #ifdef FAULTLOGGERD_TEST 27 const char* const SERVER_SOCKET_NAME = "test.faultloggerd.server"; 28 const char* const SERVER_CRASH_SOCKET_NAME = "test.faultloggerd.crash.server"; 29 const char* const SERVER_SDKDUMP_SOCKET_NAME = "test.faultloggerd.sdkdump.server"; 30 #else 31 const char* const SERVER_SOCKET_NAME = "faultloggerd.server"; 32 const char* const SERVER_CRASH_SOCKET_NAME = "faultloggerd.crash.server"; 33 const char* const SERVER_SDKDUMP_SOCKET_NAME = "faultloggerd.sdkdump.server"; 34 #endif 35 36 bool StartListen(int32_t& sockFd, const char* name, uint32_t listenCnt); 37 bool StartConnect(int32_t sockFd, const char* socketName, uint32_t timeout); 38 int32_t CreateSocketFd(); 39 bool SendFileDescriptorToSocket(int32_t sockFd, const int32_t* fds, uint32_t nFds); 40 bool ReadFileDescriptorFromSocket(int32_t sockFd, int32_t* fds, uint32_t nFds); 41 42 bool SendMsgToSocket(int32_t sockFd, const void* data, uint32_t dataLength); 43 bool GetMsgFromSocket(int32_t sockFd, void* data, uint32_t dataLength); 44 #ifdef __cplusplus 45 } 46 #endif 47 #endif 48