lsquic_ev_log.h revision 55cd0b38
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#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 (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 (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 (lsquic_cid_t, const struct stream_frame *);
52
53#define EV_LOG_STREAM_FRAME_IN(...) do {                                    \
54    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
55        lsquic_ev_log_stream_frame_in(__VA_ARGS__);                         \
56} while (0)
57
58void
59lsquic_ev_log_window_update_frame_in (lsquic_cid_t, uint32_t stream_id,
60                                                            uint64_t offset);
61
62#define EV_LOG_WINDOW_UPDATE_FRAME_IN(...) do {                             \
63    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
64        lsquic_ev_log_window_update_frame_in(__VA_ARGS__);                  \
65} while (0)
66
67void
68lsquic_ev_log_blocked_frame_in (lsquic_cid_t, uint32_t stream_id);
69
70#define EV_LOG_BLOCKED_FRAME_IN(...) do {                                   \
71    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
72        lsquic_ev_log_blocked_frame_in(__VA_ARGS__);                        \
73} while (0)
74
75void
76lsquic_ev_log_stop_waiting_frame_in (lsquic_cid_t, lsquic_packno_t);
77
78#define EV_LOG_STOP_WAITING_FRAME_IN(...) do {                              \
79    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
80        lsquic_ev_log_stop_waiting_frame_in(__VA_ARGS__);                   \
81} while (0)
82
83void
84lsquic_ev_log_connection_close_frame_in (lsquic_cid_t, uint32_t error_code,
85                                        int reason_len, const char *reason);
86
87#define EV_LOG_CONNECTION_CLOSE_FRAME_IN(...) do {                          \
88    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
89        lsquic_ev_log_connection_close_frame_in(__VA_ARGS__);               \
90} while (0)
91
92void
93lsquic_ev_log_goaway_frame_in (lsquic_cid_t, uint32_t error_code,
94                uint32_t stream_id, int reason_len, const char *reason);
95
96#define EV_LOG_GOAWAY_FRAME_IN(...) do {                                    \
97    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
98        lsquic_ev_log_goaway_frame_in(__VA_ARGS__);                         \
99} while (0)
100
101void
102lsquic_ev_log_rst_stream_frame_in (lsquic_cid_t, uint32_t stream_id,
103                                        uint64_t offset, uint32_t error_code);
104
105#define EV_LOG_RST_STREAM_FRAME_IN(...) do {                                \
106    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
107        lsquic_ev_log_rst_stream_frame_in(__VA_ARGS__);                     \
108} while (0)
109
110void
111lsquic_ev_log_padding_frame_in (lsquic_cid_t, size_t len);
112
113#define EV_LOG_PADDING_FRAME_IN(...) do {                                   \
114    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
115        lsquic_ev_log_padding_frame_in(__VA_ARGS__);                        \
116} while (0)
117
118void
119lsquic_ev_log_ping_frame_in (lsquic_cid_t);
120
121#define EV_LOG_PING_FRAME_IN(...) do {                                      \
122    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
123        lsquic_ev_log_ping_frame_in(__VA_ARGS__);                           \
124} while (0)
125
126void
127lsquic_ev_log_packet_created (lsquic_cid_t, const struct lsquic_packet_out *);
128
129#define EV_LOG_PACKET_CREATED(...) do {                                     \
130    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
131        lsquic_ev_log_packet_created(__VA_ARGS__);                          \
132} while (0)
133
134void
135lsquic_ev_log_packet_sent (lsquic_cid_t, const struct lsquic_packet_out *);
136
137#define EV_LOG_PACKET_SENT(...) do {                                        \
138    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
139        lsquic_ev_log_packet_sent(__VA_ARGS__);                             \
140} while (0)
141
142void
143lsquic_ev_log_packet_not_sent (lsquic_cid_t, const struct lsquic_packet_out *);
144
145#define EV_LOG_PACKET_NOT_SENT(...) do {                                    \
146    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
147        lsquic_ev_log_packet_not_sent(__VA_ARGS__);                         \
148} while (0)
149
150void
151lsquic_ev_log_http_headers_in (lsquic_cid_t, int is_server,
152                                        const struct uncompressed_headers *);
153
154#define EV_LOG_HTTP_HEADERS_IN(...) do {                                    \
155    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
156        lsquic_ev_log_http_headers_in(__VA_ARGS__);                         \
157} while (0)
158
159void
160lsquic_ev_log_action_stream_frame (lsquic_cid_t, const struct parse_funcs *pf,
161                       const unsigned char *, size_t len, const char *action);
162
163#define EV_LOG_GENERATED_STREAM_FRAME(...) do {                             \
164    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
165        lsquic_ev_log_action_stream_frame(__VA_ARGS__, "generated");        \
166} while (0)
167
168#define EV_LOG_UPDATED_STREAM_FRAME(...) do {                               \
169    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
170        lsquic_ev_log_action_stream_frame(__VA_ARGS__, "updated");          \
171} while (0)
172
173void
174lsquic_ev_log_generated_ack_frame (lsquic_cid_t, const struct parse_funcs *,
175                                            const unsigned char *, size_t len);
176
177#define EV_LOG_GENERATED_ACK_FRAME(...) do {                                \
178    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
179        lsquic_ev_log_generated_ack_frame(__VA_ARGS__);                     \
180} while (0)
181
182void
183lsquic_ev_log_generated_stop_waiting_frame (lsquic_cid_t, lsquic_packno_t);
184
185#define EV_LOG_GENERATED_STOP_WAITING_FRAME(...) do {                       \
186    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
187        lsquic_ev_log_generated_stop_waiting_frame(__VA_ARGS__);            \
188} while (0)
189
190void
191lsquic_ev_log_generated_http_headers (lsquic_cid_t, uint32_t stream_id,
192                            int is_server, const struct http_prio_frame *,
193                            const struct lsquic_http_headers *);
194
195
196#define EV_LOG_GENERATED_HTTP_HEADERS(...) do {                             \
197    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
198        lsquic_ev_log_generated_http_headers(__VA_ARGS__);                  \
199} while (0)
200
201void
202lsquic_ev_log_generated_http_push_promise (lsquic_cid_t, uint32_t stream_id,
203                            uint32_t promised_stream_id,
204                            const struct lsquic_http_headers *headers,
205                            const struct lsquic_http_headers *extra_headers);
206
207#define EV_LOG_GENERATED_HTTP_PUSH_PROMISE(...) do {                        \
208    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
209        lsquic_ev_log_generated_http_push_promise(__VA_ARGS__);             \
210} while (0)
211
212void
213lsquic_ev_log_create_connection (lsquic_cid_t, const struct sockaddr *,
214                                                    const struct sockaddr *);
215
216#define EV_LOG_CREATE_CONN(...) do {                                        \
217    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
218        lsquic_ev_log_create_connection(__VA_ARGS__);                       \
219    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG))                     \
220        lsquic_qlog_create_connection(__VA_ARGS__);                         \
221} while (0)
222
223void
224lsquic_ev_log_hsk_completed (lsquic_cid_t);
225
226#define EV_LOG_HSK_COMPLETED(...) do {                                      \
227    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
228        lsquic_ev_log_hsk_completed(__VA_ARGS__);                           \
229    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG))                     \
230        lsquic_qlog_hsk_completed(__VA_ARGS__);                             \
231} while (0)
232
233
234void
235lsquic_ev_log_zero_rtt (lsquic_cid_t);
236
237#define EV_LOG_ZERO_RTT(...) do {                                           \
238    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
239        lsquic_ev_log_zero_rtt(__VA_ARGS__);                                \
240    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG))                     \
241        lsquic_qlog_zero_rtt(__VA_ARGS__);                                  \
242} while (0)
243
244void
245lsquic_ev_log_check_certs (lsquic_cid_t, const lsquic_str_t **, size_t);
246
247#define EV_LOG_CHECK_CERTS(...) do {                                        \
248    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
249        lsquic_ev_log_check_certs(__VA_ARGS__);                             \
250    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG))                     \
251        lsquic_qlog_check_certs(__VA_ARGS__);                               \
252} while (0)
253
254void
255lsquic_ev_log_version_negotiation (lsquic_cid_t, const char *, const char *);
256
257#define EV_LOG_VER_NEG(...) do {                                            \
258    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
259        lsquic_ev_log_version_negotiation(__VA_ARGS__);                     \
260    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG))                     \
261        lsquic_qlog_version_negotiation(__VA_ARGS__);                       \
262} while (0)
263
264#endif
265