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