]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/cmp_util.h
chunk 6 of CMP contribution to OpenSSL
[thirdparty/openssl.git] / include / openssl / cmp_util.h
CommitLineData
7960dbec
DDO
1/*
2 * Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
3 * Copyright Nokia 2007-2019
4 * Copyright Siemens AG 2015-2019
5 *
6 * Licensed under the Apache License 2.0 (the "License"). You may not use
7 * this file except in compliance with the License. You can obtain a copy
8 * in the file LICENSE in the source distribution or at
9 * https://www.openssl.org/source/license.html
10 */
11
ae4186b0
DMSP
12#ifndef OPENSSL_CMP_UTIL_H
13# define OPENSSL_CMP_UTIL_H
7960dbec
DDO
14
15# include <openssl/opensslconf.h>
16# ifndef OPENSSL_NO_CMP
17
18# include <openssl/macros.h>
19# include <openssl/trace.h>
20# include <openssl/x509.h>
21
22# ifdef __cplusplus
23extern "C" {
24# endif
25
26/*
27 * convenience functions for CMP-specific logging via the trace API
28 */
7960dbec
DDO
29int OSSL_CMP_log_open(void);
30void OSSL_CMP_log_close(void);
31# define OSSL_CMP_LOG_PREFIX "CMP "
32/* in OSSL_CMP_LOG_START, cannot use OPENSSL_FUNC when expands to __func__ */
33# define OSSL_CMP_LOG_START "%s:" OPENSSL_FILE ":" \
3dbc5156 34 OPENSSL_MSTR(OPENSSL_LINE) ":" OSSL_CMP_LOG_PREFIX
7960dbec
DDO
35# define OSSL_CMP_alert(msg) OSSL_CMP_log(ALERT, msg)
36# define OSSL_CMP_err(msg) OSSL_CMP_log(ERROR, msg)
37# define OSSL_CMP_warn(msg) OSSL_CMP_log(WARN, msg)
38# define OSSL_CMP_info(msg) OSSL_CMP_log(INFO, msg)
39# define OSSL_CMP_debug(msg) OSSL_CMP_log(DEBUG, msg)
40# define OSSL_CMP_log(level, msg) \
41 OSSL_TRACEV(CMP, (trc_out, OSSL_CMP_LOG_START#level ": %s\n", \
42 OPENSSL_FUNC, msg))
43# define OSSL_CMP_log1(level, fmt, arg1) \
44 OSSL_TRACEV(CMP, (trc_out, OSSL_CMP_LOG_START#level ": " fmt "\n", \
45 OPENSSL_FUNC, arg1))
46# define OSSL_CMP_log2(level, fmt, arg1, arg2) \
47 OSSL_TRACEV(CMP, (trc_out, OSSL_CMP_LOG_START#level ": " fmt "\n", \
48 OPENSSL_FUNC, arg1, arg2))
49# define OSSL_CMP_log3(level, fmt, arg1, arg2, arg3) \
50 OSSL_TRACEV(CMP, (trc_out, OSSL_CMP_LOG_START#level ": " fmt "\n", \
51 OPENSSL_FUNC, arg1, arg2, arg3))
52# define OSSL_CMP_log4(level, fmt, arg1, arg2, arg3, arg4) \
53 OSSL_TRACEV(CMP, (trc_out, OSSL_CMP_LOG_START#level ": " fmt "\n", \
54 OPENSSL_FUNC, arg1, arg2, arg3, arg4))
55
56/*
57 * generalized logging/error callback mirroring the severity levels of syslog.h
58 */
59typedef int OSSL_CMP_severity;
60# define OSSL_CMP_LOG_EMERG 0
61# define OSSL_CMP_LOG_ALERT 1
62# define OSSL_CMP_LOG_CRIT 2
63# define OSSL_CMP_LOG_ERR 3
64# define OSSL_CMP_LOG_WARNING 4
65# define OSSL_CMP_LOG_NOTICE 5
66# define OSSL_CMP_LOG_INFO 6
67# define OSSL_CMP_LOG_DEBUG 7
68typedef int (*OSSL_cmp_log_cb_t)(const char *func, const char *file, int line,
69 OSSL_CMP_severity level, const char *msg);
70
71/* use of the logging callback for outputting error queue */
72void OSSL_CMP_print_errors_cb(OSSL_cmp_log_cb_t log_fn);
73
3dbc5156 74# ifdef __cplusplus
7960dbec 75}
3dbc5156 76# endif
7960dbec 77# endif /* !defined OPENSSL_NO_CMP */
ae4186b0 78#endif /* !defined OPENSSL_CMP_UTIL_H */