• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #ifndef DFX_FAULTLOGGERD_H
16 #define DFX_FAULTLOGGERD_H
17 
18 #include <cinttypes>
19 #include "faultloggerd_client.h"
20 
21 namespace OHOS {
22 namespace HiviewDFX {
23 class FaultLoggerDaemon {
24 public:
25     FaultLoggerDaemon();
~FaultLoggerDaemon()26     ~FaultLoggerDaemon() {};
27     int32_t StartServer();
28     bool InitEnvironment();
29     void LoopAcceptRequestAndFork(int socketFd);
30     int32_t CreateFileForRequest(int32_t type, int32_t pid, uint64_t time, bool debugFlag) const;
31 
32 private:
33     static void HandleRequesting(int32_t connectionFd);
34     void RemoveTempFileIfNeed();
35     void HandleRequest(int32_t connectionFd);
36     void HandleDefaultClientRequest(int32_t connectionFd, const FaultLoggerdRequest* request);
37     void HandleLogFileDesClientRequest(int32_t connectionFd, const FaultLoggerdRequest* request);
38     void HandlePrintTHilogClientRequest(int32_t const connectionFd, FaultLoggerdRequest* request);
39     FaultLoggerCheckPermissionResp SecurityCheck(int32_t connectionFd, FaultLoggerdRequest* request);
40     void HandlePermissionRequest(int32_t connectionFd, FaultLoggerdRequest* request);
41     void HandleSdkDumpRequest(int32_t connectionFd, FaultLoggerdRequest* request);
42     void HandlePipeFdClientRequest(int32_t connectionFd, const FaultLoggerdRequest* request);
43 
44 private:
45     static FaultLoggerDaemon* faultLoggerDaemon_;
46 };
47 } // namespace HiviewDFX
48 } // namespace OHOS
49 #endif
50