1 /*
2  * Copyright (C) 2018-2022 Intel Corporation.
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 /*
7  * Copyright (C) 2018-2022 Intel Corporation.
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #ifndef __PROBEUTILS_H__
23 #define __PROBEUTILS_H__
24 
25 #define UPTIME_SIZE 24
26 #define LONG_TIME_SIZE 32
27 #define SHORT_KEY_LENGTH 20
28 #define LONG_KEY_LENGTH 32
29 
30 enum e_dir_mode {
31 	MODE_CRASH = 0,
32 	MODE_STATS,
33 	MODE_VMEVENT,
34 };
35 
36 enum key_type {
37 	KEY_SHORT = 0,
38 	KEY_LONG,
39 };
40 
41 int get_uptime_string(char *newuptime, int *hours);
42 int get_current_time_long(char *buf);
43 unsigned long long get_uptime(void);
44 char *generate_event_id(const char *seed1, size_t slen1, const char *seed2,
45 			size_t slen2, enum key_type type);
46 void generate_crashfile(const char *dir, const char *event, size_t elen,
47 			const char *hashkey, size_t hlen,
48 			const char *type, size_t tlen, const char *data0,
49 			size_t d0len, const char *data1, size_t d1len,
50 			const char *data2, size_t d2len);
51 char *generate_log_dir(enum e_dir_mode mode, char *hashkey, size_t *dlen);
52 int is_boot_id_changed(void);
53 
54 #endif
55