lsquic_ev_log.h revision 229fce07
1/* Copyright (c) 2017 - 2019 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 11struct ack_info; 12struct http_prio_frame; 13struct lsquic_http_headers; 14struct lsquic_packet_in; 15struct lsquic_packet_out; 16struct parse_funcs; 17struct stream_frame; 18struct uncompressed_headers; 19 20 21/* Log a generic event not tied to any particular connection */ 22#define EV_LOG_GENERIC_EVENT(...) do { \ 23 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 24 lsquic_logger_log1(LSQ_LOG_DEBUG, LSQLM_EVENT, __VA_ARGS__); \ 25} while (0) 26 27/* Log a generic event associated with connection `cid' */ 28#define EV_LOG_CONN_EVENT(cid, ...) do { \ 29 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 30 lsquic_logger_log2(LSQ_LOG_DEBUG, LSQLM_EVENT, cid, __VA_ARGS__); \ 31} while (0) 32 33void 34lsquic_ev_log_packet_in (lsquic_cid_t, const struct lsquic_packet_in *); 35 36#define EV_LOG_PACKET_IN(...) do { \ 37 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 38 lsquic_ev_log_packet_in(__VA_ARGS__); \ 39} while (0) 40 41void 42lsquic_ev_log_ack_frame_in (lsquic_cid_t, const struct ack_info *); 43 44#define EV_LOG_ACK_FRAME_IN(...) do { \ 45 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 46 lsquic_ev_log_ack_frame_in(__VA_ARGS__); \ 47} while (0) 48 49void 50lsquic_ev_log_stream_frame_in (lsquic_cid_t, const struct stream_frame *); 51 52#define EV_LOG_STREAM_FRAME_IN(...) do { \ 53 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 54 lsquic_ev_log_stream_frame_in(__VA_ARGS__); \ 55} while (0) 56 57void 58lsquic_ev_log_window_update_frame_in (lsquic_cid_t, uint32_t stream_id, 59 uint64_t offset); 60 61#define EV_LOG_WINDOW_UPDATE_FRAME_IN(...) do { \ 62 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 63 lsquic_ev_log_window_update_frame_in(__VA_ARGS__); \ 64} while (0) 65 66void 67lsquic_ev_log_blocked_frame_in (lsquic_cid_t, uint32_t stream_id); 68 69#define EV_LOG_BLOCKED_FRAME_IN(...) do { \ 70 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 71 lsquic_ev_log_blocked_frame_in(__VA_ARGS__); \ 72} while (0) 73 74void 75lsquic_ev_log_stop_waiting_frame_in (lsquic_cid_t, lsquic_packno_t); 76 77#define EV_LOG_STOP_WAITING_FRAME_IN(...) do { \ 78 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 79 lsquic_ev_log_stop_waiting_frame_in(__VA_ARGS__); \ 80} while (0) 81 82void 83lsquic_ev_log_connection_close_frame_in (lsquic_cid_t, uint32_t error_code, 84 int reason_len, const char *reason); 85 86#define EV_LOG_CONNECTION_CLOSE_FRAME_IN(...) do { \ 87 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 88 lsquic_ev_log_connection_close_frame_in(__VA_ARGS__); \ 89} while (0) 90 91void 92lsquic_ev_log_goaway_frame_in (lsquic_cid_t, uint32_t error_code, 93 uint32_t stream_id, int reason_len, const char *reason); 94 95#define EV_LOG_GOAWAY_FRAME_IN(...) do { \ 96 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 97 lsquic_ev_log_goaway_frame_in(__VA_ARGS__); \ 98} while (0) 99 100void 101lsquic_ev_log_rst_stream_frame_in (lsquic_cid_t, uint32_t stream_id, 102 uint64_t offset, uint32_t error_code); 103 104#define EV_LOG_RST_STREAM_FRAME_IN(...) do { \ 105 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 106 lsquic_ev_log_rst_stream_frame_in(__VA_ARGS__); \ 107} while (0) 108 109void 110lsquic_ev_log_padding_frame_in (lsquic_cid_t, size_t len); 111 112#define EV_LOG_PADDING_FRAME_IN(...) do { \ 113 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 114 lsquic_ev_log_padding_frame_in(__VA_ARGS__); \ 115} while (0) 116 117void 118lsquic_ev_log_ping_frame_in (lsquic_cid_t); 119 120#define EV_LOG_PING_FRAME_IN(...) do { \ 121 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 122 lsquic_ev_log_ping_frame_in(__VA_ARGS__); \ 123} while (0) 124 125void 126lsquic_ev_log_packet_created (lsquic_cid_t, const struct lsquic_packet_out *); 127 128#define EV_LOG_PACKET_CREATED(...) do { \ 129 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 130 lsquic_ev_log_packet_created(__VA_ARGS__); \ 131} while (0) 132 133void 134lsquic_ev_log_packet_sent (lsquic_cid_t, const struct lsquic_packet_out *); 135 136#define EV_LOG_PACKET_SENT(...) do { \ 137 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 138 lsquic_ev_log_packet_sent(__VA_ARGS__); \ 139} while (0) 140 141void 142lsquic_ev_log_packet_not_sent (lsquic_cid_t, const struct lsquic_packet_out *); 143 144#define EV_LOG_PACKET_NOT_SENT(...) do { \ 145 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 146 lsquic_ev_log_packet_not_sent(__VA_ARGS__); \ 147} while (0) 148 149void 150lsquic_ev_log_http_headers_in (lsquic_cid_t, int is_server, 151 const struct uncompressed_headers *); 152 153#define EV_LOG_HTTP_HEADERS_IN(...) do { \ 154 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 155 lsquic_ev_log_http_headers_in(__VA_ARGS__); \ 156} while (0) 157 158void 159lsquic_ev_log_action_stream_frame (lsquic_cid_t, const struct parse_funcs *pf, 160 const unsigned char *, size_t len, const char *action); 161 162#define EV_LOG_GENERATED_STREAM_FRAME(...) do { \ 163 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 164 lsquic_ev_log_action_stream_frame(__VA_ARGS__, "generated"); \ 165} while (0) 166 167#define EV_LOG_UPDATED_STREAM_FRAME(...) do { \ 168 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 169 lsquic_ev_log_action_stream_frame(__VA_ARGS__, "updated"); \ 170} while (0) 171 172void 173lsquic_ev_log_generated_ack_frame (lsquic_cid_t, const struct parse_funcs *, 174 const unsigned char *, size_t len); 175 176#define EV_LOG_GENERATED_ACK_FRAME(...) do { \ 177 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 178 lsquic_ev_log_generated_ack_frame(__VA_ARGS__); \ 179} while (0) 180 181void 182lsquic_ev_log_generated_stop_waiting_frame (lsquic_cid_t, lsquic_packno_t); 183 184#define EV_LOG_GENERATED_STOP_WAITING_FRAME(...) do { \ 185 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 186 lsquic_ev_log_generated_stop_waiting_frame(__VA_ARGS__); \ 187} while (0) 188 189void 190lsquic_ev_log_generated_http_headers (lsquic_cid_t, uint32_t stream_id, 191 int is_server, const struct http_prio_frame *, 192 const struct lsquic_http_headers *); 193 194 195#define EV_LOG_GENERATED_HTTP_HEADERS(...) do { \ 196 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 197 lsquic_ev_log_generated_http_headers(__VA_ARGS__); \ 198} while (0) 199 200void 201lsquic_ev_log_generated_http_push_promise (lsquic_cid_t, uint32_t stream_id, 202 uint32_t promised_stream_id, 203 const struct lsquic_http_headers *headers, 204 const struct lsquic_http_headers *extra_headers); 205 206#define EV_LOG_GENERATED_HTTP_PUSH_PROMISE(...) do { \ 207 if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \ 208 lsquic_ev_log_generated_http_push_promise(__VA_ARGS__); \ 209} while (0) 210 211#endif 212