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 NSTACKX_STATISTICS_H
17 #define NSTACKX_STATISTICS_H
18 #include <stdint.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 typedef enum {
25     STATS_INVALID_OPT_AND_PAYLOAD,
26     STATS_DECODE_FAILED,
27     STATS_ENCODE_FAILED,
28     STATS_CREATE_HEADER_FAILED,
29     STATS_BUILD_PKT_FAILED,
30     STATS_SOCKET_ERROR,
31     STATS_EPOLL_ERROR,
32     STATS_CREATE_SERVER_FAILED,
33     STATS_CREATE_CLIENT_FAILED,
34     STATS_DROP_LOOPBACK_PKT,
35     STATS_SEND_MSG_FAILED,
36     STATS_SEND_REQUEST_FAILED,
37     STATS_DROP_MSG_ID,
38     STATS_HANDLE_SERVICE_MSG_FAILED,
39     STATS_HANDLE_DEVICE_DISCOVER_MSG_FAILED,
40     STATS_INVALID_RESPONSE_MSG,
41     STATS_POST_SD_REQUEST_FAILED,
42     STATS_ABORT_SD,
43     STATS_START_SD_FAILED,
44     STATS_CREATE_SERVICE_MSG_FAILED,
45     STATS_SEND_SD_RESPONSE_FAILED,
46     STATS_BACKUP_DEVICE_DB_FAILED,
47     STATS_UPDATE_DEVICE_DB_FAILED,
48     STATS_CREATE_CONTEX_FAILED,
49     STATS_CREATE_SESSION_FAILED,
50     STATS_PREPARE_SD_MSG_FAILED,
51     STATS_PARSE_SD_MSG_FAILED,
52     STATS_ALLOC_RECORD_FAILED,
53     STATS_FREE_RECORD_FAILED,
54     STATS_OVER_DEVICE_LIMIT,
55     STATS_COAP_RESOURCE_INIT_FAILED,
56     STATS_PREPARE_SN_MSG_FAILED,
57     STATS_MAX
58 } StatisticsType;
59 
60 void ResetStatistics(void);
61 void IncStatistics(StatisticsType type);
62 const uint64_t *GetStatistics(void);
63 
64 #ifdef __cplusplus
65 }
66 #endif
67 
68 #endif
69