Path: blob/main/crypto/openssl/include/internal/qlog.h
34879 views
/*1* Copyright 2023-2024 The OpenSSL Project Authors. All Rights Reserved.2*3* Licensed under the Apache License 2.0 (the "License"). You may not use4* this file except in compliance with the License. You can obtain a copy5* in the file LICENSE in the source distribution or at6* https://www.openssl.org/source/license.html7*/89#ifndef OSSL_QLOG_H10# define OSSL_QLOG_H1112# include <openssl/ssl.h>13# include "internal/quic_types.h"14# include "internal/time.h"1516typedef struct qlog_st QLOG;1718# ifndef OPENSSL_NO_QLOG1920enum {21QLOG_EVENT_TYPE_NONE,2223# define QLOG_EVENT(cat, name) QLOG_EVENT_TYPE_##cat##_##name,24# include "internal/qlog_events.h"25# undef QLOG_EVENT2627QLOG_EVENT_TYPE_NUM28};2930typedef struct qlog_trace_info_st {31QUIC_CONN_ID odcid;32const char *title, *description, *group_id;33int is_server;34OSSL_TIME (*now_cb)(void *arg);35void *now_cb_arg;36uint64_t override_process_id;37const char *override_impl_name;38} QLOG_TRACE_INFO;3940QLOG *ossl_qlog_new(const QLOG_TRACE_INFO *info);41QLOG *ossl_qlog_new_from_env(const QLOG_TRACE_INFO *info);4243void ossl_qlog_free(QLOG *qlog);4445/* Configuration */46int ossl_qlog_set_event_type_enabled(QLOG *qlog, uint32_t event_type,47int enable);48int ossl_qlog_set_filter(QLOG *qlog, const char *filter);4950int ossl_qlog_set_sink_bio(QLOG *qlog, BIO *bio);51# ifndef OPENSSL_NO_STDIO52int ossl_qlog_set_sink_file(QLOG *qlog, FILE *file, int close_flag);53# endif54int ossl_qlog_set_sink_filename(QLOG *qlog, const char *filename);5556/* Operations */57int ossl_qlog_flush(QLOG *qlog);5859/* Queries */60int ossl_qlog_enabled(QLOG *qlog, uint32_t event_type);6162/* Grouping Functions */63int ossl_qlog_event_try_begin(QLOG *qlog, uint32_t event_type,64const char *event_cat, const char *event_name,65const char *event_combined_name);66void ossl_qlog_event_end(QLOG *qlog);6768void ossl_qlog_group_begin(QLOG *qlog, const char *name);69void ossl_qlog_group_end(QLOG *qlog);7071void ossl_qlog_array_begin(QLOG *qlog, const char *name);72void ossl_qlog_array_end(QLOG *qlog);7374void ossl_qlog_override_time(QLOG *qlog, OSSL_TIME event_time);7576/* Grouping Macros */77# define QLOG_EVENT_BEGIN(qlog, cat, name) \78{ \79QLOG *qlog_instance = (qlog); \80uint32_t qlog_event_type = QLOG_EVENT_TYPE_##cat##_##name; \81\82if (ossl_qlog_event_try_begin(qlog_instance, qlog_event_type, \83#cat, #name, #cat ":" #name)) {8485# define QLOG_EVENT_END() \86ossl_qlog_event_end(qlog_instance); \87} \88}8990# define QLOG_BEGIN(name) \91{ \92ossl_qlog_group_begin(qlog_instance, (name));9394# define QLOG_END() \95ossl_qlog_group_end(qlog_instance); \96}9798# define QLOG_BEGIN_ARRAY(name) \99{ \100ossl_qlog_array_begin(qlog_instance, (name));101102# define QLOG_END_ARRAY() \103ossl_qlog_array_end(qlog_instance); \104}105106/* Field Functions */107void ossl_qlog_str(QLOG *qlog, const char *name, const char *value);108void ossl_qlog_str_len(QLOG *qlog, const char *name,109const char *value, size_t value_len);110void ossl_qlog_u64(QLOG *qlog, const char *name, uint64_t value);111void ossl_qlog_i64(QLOG *qlog, const char *name, int64_t value);112void ossl_qlog_bool(QLOG *qlog, const char *name, int value);113void ossl_qlog_bin(QLOG *qlog, const char *name,114const void *value, size_t value_len);115116/* Field Macros */117# define QLOG_STR(name, value) ossl_qlog_str(qlog_instance, (name), (value))118# define QLOG_STR_LEN(name, value, value_len) \119ossl_qlog_str_len(qlog_instance, (name), (value), (value_len))120# define QLOG_I64(name, value) ossl_qlog_i64(qlog_instance, (name), (value))121# define QLOG_U64(name, value) ossl_qlog_u64(qlog_instance, (name), (value))122# define QLOG_F64(name, value) ossl_qlog_f64(qlog_instance, (name), (value))123# define QLOG_BOOL(name, value) ossl_qlog_bool(qlog_instance, (name), (value))124# define QLOG_BIN(name, value, value_len) \125ossl_qlog_bin(qlog_instance, (name), (value), (value_len))126# define QLOG_CID(name, value) QLOG_BIN((name), (value)->id, (value)->id_len)127128# endif129130#endif131132133