lsquic_ev_log.h revision 50aadb33
1/* Copyright (c) 2017 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(args...) do {                                  \
23    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
24        lsquic_logger_log1(LSQ_LOG_DEBUG, LSQLM_EVENT, args);               \
25} while (0)
26
27/* Log a generic event associated with connection `cid' */
28#define EV_LOG_CONN_EVENT(cid, args...) do {                                \
29    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
30        lsquic_logger_log2(LSQ_LOG_DEBUG, LSQLM_EVENT, cid, 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(args...) do {                                      \
37    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
38        lsquic_ev_log_packet_in(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(args...) do {                                   \
45    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
46        lsquic_ev_log_ack_frame_in(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(args...) do {                                \
53    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
54        lsquic_ev_log_stream_frame_in(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(args...) do {                         \
62    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
63        lsquic_ev_log_window_update_frame_in(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(args...) do {                               \
70    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
71        lsquic_ev_log_blocked_frame_in(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(args...) do {                          \
78    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
79        lsquic_ev_log_stop_waiting_frame_in(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(args...) do {                      \
87    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
88        lsquic_ev_log_connection_close_frame_in(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(args...) do {                                \
96    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
97        lsquic_ev_log_goaway_frame_in(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(args...) do {                            \
105    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
106        lsquic_ev_log_rst_stream_frame_in(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(args...) do {                               \
113    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
114        lsquic_ev_log_padding_frame_in(args);                               \
115} while (0)
116
117void
118lsquic_ev_log_ping_frame_in (lsquic_cid_t);
119
120#define EV_LOG_PING_FRAME_IN(args...) do {                                  \
121    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
122        lsquic_ev_log_ping_frame_in(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(args...) do {                                 \
129    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
130        lsquic_ev_log_packet_created(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(args...) do {                                    \
137    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
138        lsquic_ev_log_packet_sent(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(args...) do {                                \
145    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
146        lsquic_ev_log_packet_not_sent(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(args...) do {                                \
154    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
155        lsquic_ev_log_http_headers_in(args);                                \
156} while (0)
157
158void
159lsquic_ev_log_generated_stream_frame (lsquic_cid_t, const struct parse_funcs *pf,
160                                      const unsigned char *, size_t len);
161
162#define EV_LOG_GENERATED_STREAM_FRAME(args...) do {                         \
163    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
164        lsquic_ev_log_generated_stream_frame(args);                         \
165} while (0)
166
167void
168lsquic_ev_log_generated_ack_frame (lsquic_cid_t, const struct parse_funcs *,
169                                            const unsigned char *, size_t len);
170
171#define EV_LOG_GENERATED_ACK_FRAME(args...) do {                            \
172    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
173        lsquic_ev_log_generated_ack_frame(args);                            \
174} while (0)
175
176void
177lsquic_ev_log_generated_stop_waiting_frame (lsquic_cid_t, lsquic_packno_t);
178
179#define EV_LOG_GENERATED_STOP_WAITING_FRAME(args...) do {                   \
180    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
181        lsquic_ev_log_generated_stop_waiting_frame(args);                   \
182} while (0)
183
184void
185lsquic_ev_log_generated_http_headers (lsquic_cid_t, uint32_t stream_id,
186                            int is_server, const struct http_prio_frame *,
187                            const struct lsquic_http_headers *);
188
189
190#define EV_LOG_GENERATED_HTTP_HEADERS(args...) do {                         \
191    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
192        lsquic_ev_log_generated_http_headers(args);                         \
193} while (0)
194
195void
196lsquic_ev_log_generated_http_push_promise (lsquic_cid_t, uint32_t stream_id,
197                            uint32_t promised_stream_id,
198                            const struct lsquic_http_headers *headers,
199                            const struct lsquic_http_headers *extra_headers);
200
201#define EV_LOG_GENERATED_HTTP_PUSH_PROMISE(args...) do {                    \
202    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
203        lsquic_ev_log_generated_http_push_promise(args);                    \
204} while (0)
205
206#endif
207