lsquic_ev_log.h revision 7483dee0
1/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. */ 2/* 3 * lsquic_ev_log.h -- Event logger 4 */ 5 6#ifndef LSQUIC_EV_LOG_H 7#define LSQUIC_EV_LOG_H 1 8 9#include "lsquic_int_types.h" 10#include "lsquic_qlog.h" 11 12struct ack_info; 13struct http_prio_frame; 14struct lsquic_http_headers; 15struct lsquic_packet_in; 16struct lsquic_packet_out; 17struct parse_funcs; 18struct stream_frame; 19struct uncompressed_headers; 20struct stack_st_X509; 21 22 23/* Log a generic event not tied to any particular connection */ 24#define EV_LOG_GENERIC_EVENT(...) do { \ 25 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 26 lsquic_logger_log1(LSQ_LOG_DEBUG, LSQLM_EVENT, __VA_ARGS__); \ 27} while (0) 28 29/* Log a generic event associated with connection `cid' */ 30#define EV_LOG_CONN_EVENT(cid, ...) do { \ 31 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 32 lsquic_logger_log2(LSQ_LOG_DEBUG, LSQLM_EVENT, cid, __VA_ARGS__); \ 33} while (0) 34 35void 36lsquic_ev_log_packet_in (const lsquic_cid_t *, const struct lsquic_packet_in *); 37 38#define EV_LOG_PACKET_IN(...) do { \ 39 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 40 lsquic_ev_log_packet_in(__VA_ARGS__); \ 41} while (0) 42 43void 44lsquic_ev_log_ack_frame_in (const lsquic_cid_t *, const struct ack_info *); 45 46#define EV_LOG_ACK_FRAME_IN(...) do { \ 47 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 48 lsquic_ev_log_ack_frame_in(__VA_ARGS__); \ 49} while (0) 50 51void 52lsquic_ev_log_stream_frame_in (const lsquic_cid_t *, 53 const struct stream_frame *); 54 55#define EV_LOG_STREAM_FRAME_IN(...) do { \ 56 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 57 lsquic_ev_log_stream_frame_in(__VA_ARGS__); \ 58} while (0) 59 60void 61lsquic_ev_log_crypto_frame_in (const lsquic_cid_t *, 62 const struct stream_frame *, unsigned enc_level); 63 64#define EV_LOG_CRYPTO_FRAME_IN(...) do { \ 65 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 66 lsquic_ev_log_crypto_frame_in(__VA_ARGS__); \ 67} while (0) 68 69void 70lsquic_ev_log_window_update_frame_in (const lsquic_cid_t *, lsquic_stream_id_t, 71 uint64_t offset); 72 73#define EV_LOG_WINDOW_UPDATE_FRAME_IN(...) do { \ 74 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 75 lsquic_ev_log_window_update_frame_in(__VA_ARGS__); \ 76} while (0) 77 78void 79lsquic_ev_log_blocked_frame_in (const lsquic_cid_t *, lsquic_stream_id_t); 80 81#define EV_LOG_BLOCKED_FRAME_IN(...) do { \ 82 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 83 lsquic_ev_log_blocked_frame_in(__VA_ARGS__); \ 84} while (0) 85 86void 87lsquic_ev_log_stop_waiting_frame_in (const lsquic_cid_t *, lsquic_packno_t); 88 89#define EV_LOG_STOP_WAITING_FRAME_IN(...) do { \ 90 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 91 lsquic_ev_log_stop_waiting_frame_in(__VA_ARGS__); \ 92} while (0) 93 94void 95lsquic_ev_log_connection_close_frame_in (const lsquic_cid_t *, 96 uint64_t error_code, int reason_len, const char *reason); 97 98#define EV_LOG_CONNECTION_CLOSE_FRAME_IN(...) do { \ 99 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 100 lsquic_ev_log_connection_close_frame_in(__VA_ARGS__); \ 101} while (0) 102 103void 104lsquic_ev_log_goaway_frame_in (const lsquic_cid_t *, uint32_t error_code, 105 lsquic_stream_id_t, int reason_len, const char *reason); 106 107#define EV_LOG_GOAWAY_FRAME_IN(...) do { \ 108 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 109 lsquic_ev_log_goaway_frame_in(__VA_ARGS__); \ 110} while (0) 111 112void 113lsquic_ev_log_rst_stream_frame_in (const lsquic_cid_t *, lsquic_stream_id_t, 114 uint64_t offset, uint64_t error_code); 115 116#define EV_LOG_RST_STREAM_FRAME_IN(...) do { \ 117 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 118 lsquic_ev_log_rst_stream_frame_in(__VA_ARGS__); \ 119} while (0) 120 121void 122lsquic_ev_log_stop_sending_frame_in (const lsquic_cid_t *,lsquic_stream_id_t, 123 uint64_t error_code); 124 125#define EV_LOG_STOP_SENDING_FRAME_IN(...) do { \ 126 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 127 lsquic_ev_log_stop_sending_frame_in(__VA_ARGS__); \ 128} while (0) 129 130void 131lsquic_ev_log_padding_frame_in (const lsquic_cid_t *, size_t len); 132 133#define EV_LOG_PADDING_FRAME_IN(...) do { \ 134 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 135 lsquic_ev_log_padding_frame_in(__VA_ARGS__); \ 136} while (0) 137 138void 139lsquic_ev_log_ping_frame_in (const lsquic_cid_t *); 140 141#define EV_LOG_PING_FRAME_IN(...) do { \ 142 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 143 lsquic_ev_log_ping_frame_in(__VA_ARGS__); \ 144} while (0) 145 146void 147lsquic_ev_log_packet_created (const lsquic_cid_t *, 148 const struct lsquic_packet_out *); 149 150#define EV_LOG_PACKET_CREATED(...) do { \ 151 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 152 lsquic_ev_log_packet_created(__VA_ARGS__); \ 153} while (0) 154 155void 156lsquic_ev_log_packet_sent (const lsquic_cid_t *, 157 const struct lsquic_packet_out *); 158 159#define EV_LOG_PACKET_SENT(...) do { \ 160 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 161 lsquic_ev_log_packet_sent(__VA_ARGS__); \ 162} while (0) 163 164void 165lsquic_ev_log_packet_not_sent (const lsquic_cid_t *, 166 const struct lsquic_packet_out *); 167 168#define EV_LOG_PACKET_NOT_SENT(...) do { \ 169 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 170 lsquic_ev_log_packet_not_sent(__VA_ARGS__); \ 171} while (0) 172 173void 174lsquic_ev_log_http_headers_in (const lsquic_cid_t *, int is_server, 175 const struct uncompressed_headers *); 176 177#define EV_LOG_HTTP_HEADERS_IN(...) do { \ 178 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 179 lsquic_ev_log_http_headers_in(__VA_ARGS__); \ 180} while (0) 181 182void 183lsquic_ev_log_action_stream_frame (const lsquic_cid_t *, 184 const struct parse_funcs *pf, 185 const unsigned char *, size_t len, const char *action); 186 187#define EV_LOG_GENERATED_STREAM_FRAME(...) do { \ 188 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 189 lsquic_ev_log_action_stream_frame(__VA_ARGS__, "generated"); \ 190} while (0) 191 192#define EV_LOG_UPDATED_STREAM_FRAME(...) do { \ 193 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 194 lsquic_ev_log_action_stream_frame(__VA_ARGS__, "updated"); \ 195} while (0) 196 197void 198lsquic_ev_log_generated_crypto_frame (const lsquic_cid_t *, 199 const struct parse_funcs *pf, 200 const unsigned char *, size_t len); 201 202#define EV_LOG_GENERATED_CRYPTO_FRAME(...) do { \ 203 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 204 lsquic_ev_log_generated_crypto_frame(__VA_ARGS__); \ 205} while (0) 206 207void 208lsquic_ev_log_generated_ack_frame (const lsquic_cid_t *, 209 const struct parse_funcs *, const unsigned char *, size_t len); 210 211#define EV_LOG_GENERATED_ACK_FRAME(...) do { \ 212 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 213 lsquic_ev_log_generated_ack_frame(__VA_ARGS__); \ 214} while (0) 215 216void 217lsquic_ev_log_generated_new_token_frame (const lsquic_cid_t *, 218 const struct parse_funcs *, const unsigned char *, size_t len); 219 220#define EV_LOG_GENERATED_NEW_TOKEN_FRAME(...) do { \ 221 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 222 lsquic_ev_log_generated_new_token_frame(__VA_ARGS__); \ 223} while (0) 224 225void 226lsquic_ev_log_generated_path_chal_frame (const lsquic_cid_t *, 227 const struct parse_funcs *, const unsigned char *, size_t len); 228 229#define EV_LOG_GENERATED_PATH_CHAL_FRAME(...) do { \ 230 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 231 lsquic_ev_log_generated_path_chal_frame(__VA_ARGS__); \ 232} while (0) 233 234void 235lsquic_ev_log_generated_path_resp_frame (const lsquic_cid_t *, 236 const struct parse_funcs *, const unsigned char *, size_t len); 237 238#define EV_LOG_GENERATED_PATH_RESP_FRAME(...) do { \ 239 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 240 lsquic_ev_log_generated_path_resp_frame(__VA_ARGS__); \ 241} while (0) 242 243void 244lsquic_ev_log_generated_new_connection_id_frame (const lsquic_cid_t *, 245 const struct parse_funcs *, const unsigned char *, size_t len); 246 247#define EV_LOG_GENERATED_NEW_CONNECTION_ID_FRAME(...) do { \ 248 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 249 lsquic_ev_log_generated_new_connection_id_frame(__VA_ARGS__); \ 250} while (0) 251 252void 253lsquic_ev_log_generated_stop_waiting_frame (const lsquic_cid_t *, 254 lsquic_packno_t); 255 256#define EV_LOG_GENERATED_STOP_WAITING_FRAME(...) do { \ 257 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 258 lsquic_ev_log_generated_stop_waiting_frame(__VA_ARGS__); \ 259} while (0) 260 261void 262lsquic_ev_log_generated_stop_sending_frame (const lsquic_cid_t *, 263 lsquic_stream_id_t, uint16_t); 264 265#define EV_LOG_GENERATED_STOP_SENDING_FRAME(...) do { \ 266 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 267 lsquic_ev_log_generated_stop_sending_frame(__VA_ARGS__); \ 268} while (0) 269 270void 271lsquic_ev_log_generated_http_headers (const lsquic_cid_t *, lsquic_stream_id_t, 272 int is_server, const struct http_prio_frame *, 273 const struct lsquic_http_headers *); 274 275 276#define EV_LOG_GENERATED_HTTP_HEADERS(...) do { \ 277 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 278 lsquic_ev_log_generated_http_headers(__VA_ARGS__); \ 279} while (0) 280 281void 282lsquic_ev_log_generated_http_push_promise (const lsquic_cid_t *, 283 lsquic_stream_id_t stream_id, lsquic_stream_id_t promised_stream_id, 284 const struct lsquic_http_headers *headers); 285 286#define EV_LOG_GENERATED_HTTP_PUSH_PROMISE(...) do { \ 287 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 288 lsquic_ev_log_generated_http_push_promise(__VA_ARGS__); \ 289} while (0) 290 291void 292lsquic_ev_log_create_connection (const lsquic_cid_t *, const struct sockaddr *, 293 const struct sockaddr *); 294 295#define EV_LOG_CREATE_CONN(...) do { \ 296 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 297 lsquic_ev_log_create_connection(__VA_ARGS__); \ 298 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG)) \ 299 lsquic_qlog_create_connection(__VA_ARGS__); \ 300} while (0) 301 302void 303lsquic_ev_log_hsk_completed (const lsquic_cid_t *); 304 305#define EV_LOG_HSK_COMPLETED(...) do { \ 306 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 307 lsquic_ev_log_hsk_completed(__VA_ARGS__); \ 308 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG)) \ 309 lsquic_qlog_hsk_completed(__VA_ARGS__); \ 310} while (0) 311 312 313void 314lsquic_ev_log_sess_resume (const lsquic_cid_t *); 315 316#define EV_LOG_SESSION_RESUMPTION(...) do { \ 317 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 318 lsquic_ev_log_sess_resume(__VA_ARGS__); \ 319 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG)) \ 320 lsquic_qlog_sess_resume(__VA_ARGS__); \ 321} while (0) 322 323void 324lsquic_ev_log_check_certs (const lsquic_cid_t *, const lsquic_str_t **, size_t); 325 326#define EV_LOG_CHECK_CERTS(...) do { \ 327 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 328 lsquic_ev_log_check_certs(__VA_ARGS__); \ 329 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG)) \ 330 lsquic_qlog_check_certs(__VA_ARGS__); \ 331} while (0) 332 333void 334lsquic_ev_log_cert_chain (const lsquic_cid_t *, struct stack_st_X509 *); 335 336#define EV_LOG_CERT_CHAIN(...) do { \ 337 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 338 lsquic_ev_log_cert_chain(__VA_ARGS__); \ 339 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG)) \ 340 lsquic_qlog_cert_chain(__VA_ARGS__); \ 341} while (0) 342 343void 344lsquic_ev_log_version_negotiation (const lsquic_cid_t *, const char *, const char *); 345 346#define EV_LOG_VER_NEG(...) do { \ 347 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 348 lsquic_ev_log_version_negotiation(__VA_ARGS__); \ 349 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG)) \ 350 lsquic_qlog_version_negotiation(__VA_ARGS__); \ 351} while (0) 352 353#endif 354