• 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 
16 #ifndef OHOS_IPC_DBINDER_ERROR_CODE_H
17 #define OHOS_IPC_DBINDER_ERROR_CODE_H
18 
19 #include <cmath>
20 #include <string>
21 #include "hisysevent.h"
22 
23 namespace OHOS {
24 class DbinderErrorCode {
25 public:
26     static const int SYSTEM_ENVIRONMENT_ERROR = 950000601;
27     static const int NETWORK_ERROR = 950000602;
28     static const int SKELETON_ERROR = 950000603;
29     static const int DBINDER_SERVICE_ERROR = 950000604;
30     static const int TRANSMISSION_ERROR = 950000605;
31     static const int COMMON_DRIVER_ERROR = 950000606;
32     static const int KERNEL_DRIVER_ERROR = 950000607;
33     static const int SOCKET_DRIVER_ERROR = 950000608;
34 
35     static constexpr char DSOFTBUS_DOMAIN[] = "DSOFTBUS";
36     static constexpr char DSOFTBUS_EVENT_NAME[] = "IPC_BEHAVIOR";
37     static constexpr char DSOFTBUS_PKG_NAME[] = "dsoftbus_ipc";
38 
39     inline static constexpr const char *ERROR_TYPE = "ErrType";
40     inline static constexpr const char *ERROR_CODE = "ErrCode";
41 
42     // 601
43     enum SystemEnvironmentError {
44         CREATE_EPOLL = 1,
45         BIND_EPOLL,
46         REMOVE_EPOLL,
47     };
48 
49     // 602
50     enum NetworkError {
51         WRONG_DEVICE_ID = 1,
52         WRONG_SUBSCRIPTION,
53     };
54 
55     // 603
56     enum SkeletonError {
57         WRONG_KERNEL_DRIVER = 1,
58         WRONG_SOCKET_DRIVER,
59         WRONG_TYPE_PROXY,
60         UPDATE_SESSION_FAILURE,
61         RELEASE_FD_FAILURE,
62         RELEASE_SESSION_FAILURE,
63         UNKNOWN_CMD,
64     };
65 
66     // 604
67     enum DbinderServiceError {
68         START_DBS_FAILURE = 1,
69         CLOSE_DBS_FAILURE,
70         WRONG_INPUT_PARAMETER,
71         LOCAL_OBJECT_SEND_MESSAGE_FAILURE,
72         RECEIVE_MESSAGE_FAILURE,
73         INVOKE_LISTENER_FAILURE,
74         ALLOCATE_INDEX_FAILURE,
75         REMOTE_OBJECT_SEND_MESSAGE_FAILURE,
76         INITIATE_DATABUS_FAILURE,
77         DATABUS_SEND_FAILURE,
78         DATABUS_RECEIVE_FAILURE,
79         CLOSE_DATABUS_FAILURE,
80         OPERATE_MESSAGE_FAILURE,
81     };
82 
83     // 605
84     enum TransmissionError {
85         RECEIVE_PKT_LOSS = 1,
86         SEND_PKT_LOSS,
87         HANDLE_OVERMUCH_THREADS,
88         OVERSIZE_PKT,
89     };
90 
91     // 606
92     enum CommonDriverType {
93         IPC_DRIVER = 1,
94         RPC_DRIVER,
95     };
96     enum CommonDriverError {
97         TRANSACT_DATA_FAILURE = 1,
98         HANDLE_RECV_DATA_FAILURE,
99         SET_DEATH_RECIPIENT_FAILURE,
100         REMOVE_DEATH_RECIPIENT_FAILURE,
101         HANDLE_DEATH_RECIPIENT_FAILURE,
102         FLATTEN_OBJECT_FAILURE,
103         UNFLATTEN_OBJECT_FAILURE,
104     };
105 
106     // 607
107     enum KernelDriverError {
108         INITIATE_IPC_DRIVER_FAILURE = 1,
109         OPEN_IPC_DRIVER_FAILURE,
110         WRITE_IPC_DRIVER_FAILURE,
111     };
112 
113     // 608
114     enum SocketDriverError {
115         OPEN_RPC_DRIVER_FAILURE = 1,
116         CONNECT_RPC_REMOTE_FAILURE,
117         SEND_RPC_DATA_FAILURE,
118         RECEIVE_RPC_DATA_FAILURE,
119         INVOKE_RPC_THREAD_FAILURE,
120     };
121 
122     // BIZ_SCENE
123     enum IpcEventScene {
124         IPC_COMMUNICATION = 1,
125     };
126 
127     // BIZ_STAGE
128     enum IpcEventStage {
129         IPC_MESSAGE_RPOCESS = 1,
130     };
131 
132     // BIZ_STATE
133     enum IpcEventState {
134         IPC_START = 1,
135         IPC_END,
136     };
137 
138     // STAGE_RES
139     enum IpcEventResult {
140         IPC_RESULT_IDLE = 0,
141         IPC_RESULT_OK,
142         IPC_RESULT_FAILED,
143         IPC_RESULT_CANCELED,
144         IPC_RESULT_UNKNOWN,
145     };
146 };
147 
ReportEvent(int code,const std::string & type,int num,const char * func)148 inline void ReportEvent(int code, const std::string &type, int num, const char *func)
149 {
150     if (code == 0 || type.empty() || num == 0) {
151         return;
152     }
153     return;
154 }
155 
ReportDriverEvent(int code,const std::string & type,int num,const std::string & errorType,int errorNum,const char * func)156 inline void ReportDriverEvent(int code, const std::string &type, int num, const std::string &errorType, int errorNum,
157     const char *func)
158 {
159     if (code == 0 || type.empty() || num == 0 || errorType.empty() || errorNum == 0) {
160         return;
161     }
162     return;
163 }
164 
165 } // namespace OHOS
166 #endif // OHOS_IPC_DBINDER_ERROR_CODE_H
167