]>
git.ipfire.org Git - thirdparty/openssl.git/blob - include/internal/qlog.h
8d44ed00983af4f5649c5fc7f3602d919967bc1c
2 * Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
13 # include <openssl/ssl.h>
14 # include "internal/quic_types.h"
15 # include "internal/time.h"
17 typedef struct qlog_st QLOG
;
19 # ifndef OPENSSL_NO_QLOG
24 # define QLOG_EVENT(cat, name) QLOG_EVENT_TYPE_##cat##_##name,
25 # include "internal/qlog_events.h"
31 typedef struct qlog_trace_info_st
{
33 const char *title
, *description
, *group_id
;
35 OSSL_TIME (*now_cb
)(void *arg
);
39 QLOG
*ossl_qlog_new(const QLOG_TRACE_INFO
*info
);
40 QLOG
*ossl_qlog_new_from_env(const QLOG_TRACE_INFO
*info
);
42 void ossl_qlog_free(QLOG
*qlog
);
45 int ossl_qlog_set_event_type_enabled(QLOG
*qlog
, uint32_t event_type
,
47 int ossl_qlog_set_filter(QLOG
*qlog
, const char *filter
);
49 int ossl_qlog_set_sink_bio(QLOG
*qlog
, BIO
*bio
);
50 # ifndef OPENSSL_NO_STDIO
51 int ossl_qlog_set_sink_file(QLOG
*qlog
, FILE *file
, int close_flag
);
53 int ossl_qlog_set_sink_filename(QLOG
*qlog
, const char *filename
);
56 int ossl_qlog_flush(QLOG
*qlog
);
59 int ossl_qlog_enabled(QLOG
*qlog
, uint32_t event_type
);
61 /* Grouping Functions */
62 int ossl_qlog_event_try_begin(QLOG
*qlog
, uint32_t event_type
,
63 const char *event_cat
, const char *event_name
,
64 const char *event_combined_name
);
65 void ossl_qlog_event_end(QLOG
*qlog
);
67 void ossl_qlog_group_begin(QLOG
*qlog
, const char *name
);
68 void ossl_qlog_group_end(QLOG
*qlog
);
70 void ossl_qlog_array_begin(QLOG
*qlog
, const char *name
);
71 void ossl_qlog_array_end(QLOG
*qlog
);
73 void ossl_qlog_override_time(QLOG
*qlog
, OSSL_TIME event_time
);
76 # define QLOG_EVENT_BEGIN(qlog, cat, name) \
78 QLOG *qlog_instance = (qlog); \
79 uint32_t qlog_event_type = QLOG_EVENT_TYPE_##cat##_##name; \
81 if (ossl_qlog_event_try_begin(qlog_instance, qlog_event_type, \
82 #cat, #name, #cat ":" #name)) {
84 # define QLOG_EVENT_END() \
85 ossl_qlog_event_end(qlog_instance); \
89 # define QLOG_BEGIN(name) \
91 ossl_qlog_group_begin(qlog_instance, (name));
94 ossl_qlog_group_end(qlog_instance); \
97 # define QLOG_BEGIN_ARRAY(name) \
99 ossl_qlog_array_begin(qlog_instance, (name));
101 # define QLOG_END_ARRAY() \
102 ossl_qlog_array_end(qlog_instance); \
105 /* Field Functions */
106 void ossl_qlog_str(QLOG
*qlog
, const char *name
, const char *value
);
107 void ossl_qlog_str_len(QLOG
*qlog
, const char *name
,
108 const char *value
, size_t value_len
);
109 void ossl_qlog_u64(QLOG
*qlog
, const char *name
, uint64_t value
);
110 void ossl_qlog_i64(QLOG
*qlog
, const char *name
, int64_t value
);
111 void ossl_qlog_bool(QLOG
*qlog
, const char *name
, int value
);
112 void ossl_qlog_bin(QLOG
*qlog
, const char *name
,
113 const void *value
, size_t value_len
);
116 # define QLOG_STR(name, value) ossl_qlog_str(qlog_instance, (name), (value))
117 # define QLOG_STR_LEN(name, value, value_len) \
118 ossl_qlog_str_len(qlog_instance, (name), (value), (value_len))
119 # define QLOG_I64(name, value) ossl_qlog_i64(qlog_instance, (name), (value))
120 # define QLOG_U64(name, value) ossl_qlog_u64(qlog_instance, (name), (value))
121 # define QLOG_F64(name, value) ossl_qlog_f64(qlog_instance, (name), (value))
122 # define QLOG_BOOL(name, value) ossl_qlog_bool(qlog_instance, (name), (value))
123 # define QLOG_BIN(name, value, value_len) \
124 ossl_qlog_bin(qlog_instance, (name), (value), (value_len))
125 # define QLOG_CID(name, value) QLOG_BIN((name), (value)->id, (value)->id_len)