lsquic_ev_log.h revision 229fce07
1229fce07SDmitri Tikhonov/* Copyright (c) 2017 - 2019 LiteSpeed Technologies Inc.  See LICENSE. */
250aadb33SDmitri Tikhonov/*
350aadb33SDmitri Tikhonov * lsquic_ev_log.h -- Event logger
450aadb33SDmitri Tikhonov */
550aadb33SDmitri Tikhonov
650aadb33SDmitri Tikhonov#ifndef LSQUIC_EV_LOG_H
750aadb33SDmitri Tikhonov#define LSQUIC_EV_LOG_H 1
850aadb33SDmitri Tikhonov
950aadb33SDmitri Tikhonov#include "lsquic_int_types.h"
1050aadb33SDmitri Tikhonov
1150aadb33SDmitri Tikhonovstruct ack_info;
1250aadb33SDmitri Tikhonovstruct http_prio_frame;
1350aadb33SDmitri Tikhonovstruct lsquic_http_headers;
1450aadb33SDmitri Tikhonovstruct lsquic_packet_in;
1550aadb33SDmitri Tikhonovstruct lsquic_packet_out;
1650aadb33SDmitri Tikhonovstruct parse_funcs;
1750aadb33SDmitri Tikhonovstruct stream_frame;
1850aadb33SDmitri Tikhonovstruct uncompressed_headers;
1950aadb33SDmitri Tikhonov
2050aadb33SDmitri Tikhonov
2150aadb33SDmitri Tikhonov/* Log a generic event not tied to any particular connection */
22b93f59beSBob Perper#define EV_LOG_GENERIC_EVENT(...) do {                                      \
2350aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
24b93f59beSBob Perper        lsquic_logger_log1(LSQ_LOG_DEBUG, LSQLM_EVENT, __VA_ARGS__);        \
2550aadb33SDmitri Tikhonov} while (0)
2650aadb33SDmitri Tikhonov
2750aadb33SDmitri Tikhonov/* Log a generic event associated with connection `cid' */
28b93f59beSBob Perper#define EV_LOG_CONN_EVENT(cid, ...) do {                                    \
2950aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
30b93f59beSBob Perper        lsquic_logger_log2(LSQ_LOG_DEBUG, LSQLM_EVENT, cid, __VA_ARGS__);   \
3150aadb33SDmitri Tikhonov} while (0)
3250aadb33SDmitri Tikhonov
3350aadb33SDmitri Tikhonovvoid
3450aadb33SDmitri Tikhonovlsquic_ev_log_packet_in (lsquic_cid_t, const struct lsquic_packet_in *);
3550aadb33SDmitri Tikhonov
36b93f59beSBob Perper#define EV_LOG_PACKET_IN(...) do {                                          \
3750aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
38b93f59beSBob Perper        lsquic_ev_log_packet_in(__VA_ARGS__);                               \
3950aadb33SDmitri Tikhonov} while (0)
4050aadb33SDmitri Tikhonov
4150aadb33SDmitri Tikhonovvoid
4250aadb33SDmitri Tikhonovlsquic_ev_log_ack_frame_in (lsquic_cid_t, const struct ack_info *);
4350aadb33SDmitri Tikhonov
44b93f59beSBob Perper#define EV_LOG_ACK_FRAME_IN(...) do {                                       \
4550aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
46b93f59beSBob Perper        lsquic_ev_log_ack_frame_in(__VA_ARGS__);                            \
4750aadb33SDmitri Tikhonov} while (0)
4850aadb33SDmitri Tikhonov
4950aadb33SDmitri Tikhonovvoid
5050aadb33SDmitri Tikhonovlsquic_ev_log_stream_frame_in (lsquic_cid_t, const struct stream_frame *);
5150aadb33SDmitri Tikhonov
52b93f59beSBob Perper#define EV_LOG_STREAM_FRAME_IN(...) do {                                    \
5350aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
54b93f59beSBob Perper        lsquic_ev_log_stream_frame_in(__VA_ARGS__);                         \
5550aadb33SDmitri Tikhonov} while (0)
5650aadb33SDmitri Tikhonov
5750aadb33SDmitri Tikhonovvoid
5850aadb33SDmitri Tikhonovlsquic_ev_log_window_update_frame_in (lsquic_cid_t, uint32_t stream_id,
5950aadb33SDmitri Tikhonov                                                            uint64_t offset);
6050aadb33SDmitri Tikhonov
61b93f59beSBob Perper#define EV_LOG_WINDOW_UPDATE_FRAME_IN(...) do {                             \
6250aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
63b93f59beSBob Perper        lsquic_ev_log_window_update_frame_in(__VA_ARGS__);                  \
6450aadb33SDmitri Tikhonov} while (0)
6550aadb33SDmitri Tikhonov
6650aadb33SDmitri Tikhonovvoid
6750aadb33SDmitri Tikhonovlsquic_ev_log_blocked_frame_in (lsquic_cid_t, uint32_t stream_id);
6850aadb33SDmitri Tikhonov
69b93f59beSBob Perper#define EV_LOG_BLOCKED_FRAME_IN(...) do {                                   \
7050aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
71b93f59beSBob Perper        lsquic_ev_log_blocked_frame_in(__VA_ARGS__);                        \
7250aadb33SDmitri Tikhonov} while (0)
7350aadb33SDmitri Tikhonov
7450aadb33SDmitri Tikhonovvoid
7550aadb33SDmitri Tikhonovlsquic_ev_log_stop_waiting_frame_in (lsquic_cid_t, lsquic_packno_t);
7650aadb33SDmitri Tikhonov
77b93f59beSBob Perper#define EV_LOG_STOP_WAITING_FRAME_IN(...) do {                              \
7850aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
79b93f59beSBob Perper        lsquic_ev_log_stop_waiting_frame_in(__VA_ARGS__);                   \
8050aadb33SDmitri Tikhonov} while (0)
8150aadb33SDmitri Tikhonov
8250aadb33SDmitri Tikhonovvoid
8350aadb33SDmitri Tikhonovlsquic_ev_log_connection_close_frame_in (lsquic_cid_t, uint32_t error_code,
8450aadb33SDmitri Tikhonov                                        int reason_len, const char *reason);
8550aadb33SDmitri Tikhonov
86b93f59beSBob Perper#define EV_LOG_CONNECTION_CLOSE_FRAME_IN(...) do {                          \
8750aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
88b93f59beSBob Perper        lsquic_ev_log_connection_close_frame_in(__VA_ARGS__);               \
8950aadb33SDmitri Tikhonov} while (0)
9050aadb33SDmitri Tikhonov
9150aadb33SDmitri Tikhonovvoid
9250aadb33SDmitri Tikhonovlsquic_ev_log_goaway_frame_in (lsquic_cid_t, uint32_t error_code,
9350aadb33SDmitri Tikhonov                uint32_t stream_id, int reason_len, const char *reason);
9450aadb33SDmitri Tikhonov
95b93f59beSBob Perper#define EV_LOG_GOAWAY_FRAME_IN(...) do {                                    \
9650aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
97b93f59beSBob Perper        lsquic_ev_log_goaway_frame_in(__VA_ARGS__);                         \
9850aadb33SDmitri Tikhonov} while (0)
9950aadb33SDmitri Tikhonov
10050aadb33SDmitri Tikhonovvoid
10150aadb33SDmitri Tikhonovlsquic_ev_log_rst_stream_frame_in (lsquic_cid_t, uint32_t stream_id,
10250aadb33SDmitri Tikhonov                                        uint64_t offset, uint32_t error_code);
10350aadb33SDmitri Tikhonov
104b93f59beSBob Perper#define EV_LOG_RST_STREAM_FRAME_IN(...) do {                                \
10550aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
106b93f59beSBob Perper        lsquic_ev_log_rst_stream_frame_in(__VA_ARGS__);                     \
10750aadb33SDmitri Tikhonov} while (0)
10850aadb33SDmitri Tikhonov
10950aadb33SDmitri Tikhonovvoid
11050aadb33SDmitri Tikhonovlsquic_ev_log_padding_frame_in (lsquic_cid_t, size_t len);
11150aadb33SDmitri Tikhonov
112b93f59beSBob Perper#define EV_LOG_PADDING_FRAME_IN(...) do {                                   \
11350aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
114b93f59beSBob Perper        lsquic_ev_log_padding_frame_in(__VA_ARGS__);                        \
11550aadb33SDmitri Tikhonov} while (0)
11650aadb33SDmitri Tikhonov
11750aadb33SDmitri Tikhonovvoid
11850aadb33SDmitri Tikhonovlsquic_ev_log_ping_frame_in (lsquic_cid_t);
11950aadb33SDmitri Tikhonov
120b93f59beSBob Perper#define EV_LOG_PING_FRAME_IN(...) do {                                      \
12150aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
122b93f59beSBob Perper        lsquic_ev_log_ping_frame_in(__VA_ARGS__);                           \
12350aadb33SDmitri Tikhonov} while (0)
12450aadb33SDmitri Tikhonov
12550aadb33SDmitri Tikhonovvoid
12650aadb33SDmitri Tikhonovlsquic_ev_log_packet_created (lsquic_cid_t, const struct lsquic_packet_out *);
12750aadb33SDmitri Tikhonov
128b93f59beSBob Perper#define EV_LOG_PACKET_CREATED(...) do {                                     \
12950aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
130b93f59beSBob Perper        lsquic_ev_log_packet_created(__VA_ARGS__);                          \
13150aadb33SDmitri Tikhonov} while (0)
13250aadb33SDmitri Tikhonov
13350aadb33SDmitri Tikhonovvoid
13450aadb33SDmitri Tikhonovlsquic_ev_log_packet_sent (lsquic_cid_t, const struct lsquic_packet_out *);
13550aadb33SDmitri Tikhonov
136b93f59beSBob Perper#define EV_LOG_PACKET_SENT(...) do {                                        \
13750aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
138b93f59beSBob Perper        lsquic_ev_log_packet_sent(__VA_ARGS__);                             \
13950aadb33SDmitri Tikhonov} while (0)
14050aadb33SDmitri Tikhonov
14150aadb33SDmitri Tikhonovvoid
14250aadb33SDmitri Tikhonovlsquic_ev_log_packet_not_sent (lsquic_cid_t, const struct lsquic_packet_out *);
14350aadb33SDmitri Tikhonov
144b93f59beSBob Perper#define EV_LOG_PACKET_NOT_SENT(...) do {                                    \
14550aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
146b93f59beSBob Perper        lsquic_ev_log_packet_not_sent(__VA_ARGS__);                         \
14750aadb33SDmitri Tikhonov} while (0)
14850aadb33SDmitri Tikhonov
14950aadb33SDmitri Tikhonovvoid
15050aadb33SDmitri Tikhonovlsquic_ev_log_http_headers_in (lsquic_cid_t, int is_server,
15150aadb33SDmitri Tikhonov                                        const struct uncompressed_headers *);
15250aadb33SDmitri Tikhonov
153b93f59beSBob Perper#define EV_LOG_HTTP_HEADERS_IN(...) do {                                    \
15450aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
155b93f59beSBob Perper        lsquic_ev_log_http_headers_in(__VA_ARGS__);                         \
15650aadb33SDmitri Tikhonov} while (0)
15750aadb33SDmitri Tikhonov
15850aadb33SDmitri Tikhonovvoid
159c51ce338SDmitri Tikhonovlsquic_ev_log_action_stream_frame (lsquic_cid_t, const struct parse_funcs *pf,
160c51ce338SDmitri Tikhonov                       const unsigned char *, size_t len, const char *action);
16150aadb33SDmitri Tikhonov
162b93f59beSBob Perper#define EV_LOG_GENERATED_STREAM_FRAME(...) do {                             \
16350aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
164b93f59beSBob Perper        lsquic_ev_log_action_stream_frame(__VA_ARGS__, "generated");        \
165c51ce338SDmitri Tikhonov} while (0)
166c51ce338SDmitri Tikhonov
167b93f59beSBob Perper#define EV_LOG_UPDATED_STREAM_FRAME(...) do {                               \
168c51ce338SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
169b93f59beSBob Perper        lsquic_ev_log_action_stream_frame(__VA_ARGS__, "updated");          \
17050aadb33SDmitri Tikhonov} while (0)
17150aadb33SDmitri Tikhonov
17250aadb33SDmitri Tikhonovvoid
17350aadb33SDmitri Tikhonovlsquic_ev_log_generated_ack_frame (lsquic_cid_t, const struct parse_funcs *,
17450aadb33SDmitri Tikhonov                                            const unsigned char *, size_t len);
17550aadb33SDmitri Tikhonov
176b93f59beSBob Perper#define EV_LOG_GENERATED_ACK_FRAME(...) do {                                \
17750aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
178b93f59beSBob Perper        lsquic_ev_log_generated_ack_frame(__VA_ARGS__);                     \
17950aadb33SDmitri Tikhonov} while (0)
18050aadb33SDmitri Tikhonov
18150aadb33SDmitri Tikhonovvoid
18250aadb33SDmitri Tikhonovlsquic_ev_log_generated_stop_waiting_frame (lsquic_cid_t, lsquic_packno_t);
18350aadb33SDmitri Tikhonov
184b93f59beSBob Perper#define EV_LOG_GENERATED_STOP_WAITING_FRAME(...) do {                       \
18550aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
186b93f59beSBob Perper        lsquic_ev_log_generated_stop_waiting_frame(__VA_ARGS__);            \
18750aadb33SDmitri Tikhonov} while (0)
18850aadb33SDmitri Tikhonov
18950aadb33SDmitri Tikhonovvoid
19050aadb33SDmitri Tikhonovlsquic_ev_log_generated_http_headers (lsquic_cid_t, uint32_t stream_id,
19150aadb33SDmitri Tikhonov                            int is_server, const struct http_prio_frame *,
19250aadb33SDmitri Tikhonov                            const struct lsquic_http_headers *);
19350aadb33SDmitri Tikhonov
19450aadb33SDmitri Tikhonov
195b93f59beSBob Perper#define EV_LOG_GENERATED_HTTP_HEADERS(...) do {                             \
19650aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
197b93f59beSBob Perper        lsquic_ev_log_generated_http_headers(__VA_ARGS__);                  \
19850aadb33SDmitri Tikhonov} while (0)
19950aadb33SDmitri Tikhonov
20050aadb33SDmitri Tikhonovvoid
20150aadb33SDmitri Tikhonovlsquic_ev_log_generated_http_push_promise (lsquic_cid_t, uint32_t stream_id,
20250aadb33SDmitri Tikhonov                            uint32_t promised_stream_id,
20350aadb33SDmitri Tikhonov                            const struct lsquic_http_headers *headers,
20450aadb33SDmitri Tikhonov                            const struct lsquic_http_headers *extra_headers);
20550aadb33SDmitri Tikhonov
206b93f59beSBob Perper#define EV_LOG_GENERATED_HTTP_PUSH_PROMISE(...) do {                        \
20750aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
208b93f59beSBob Perper        lsquic_ev_log_generated_http_push_promise(__VA_ARGS__);             \
20950aadb33SDmitri Tikhonov} while (0)
21050aadb33SDmitri Tikhonov
21150aadb33SDmitri Tikhonov#endif
212