lsquic_ev_log.h revision 55cd0b38
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"
1055cd0b38SDmitri Tikhonov#include "lsquic_qlog.h"
1150aadb33SDmitri Tikhonov
1250aadb33SDmitri Tikhonovstruct ack_info;
1350aadb33SDmitri Tikhonovstruct http_prio_frame;
1450aadb33SDmitri Tikhonovstruct lsquic_http_headers;
1550aadb33SDmitri Tikhonovstruct lsquic_packet_in;
1650aadb33SDmitri Tikhonovstruct lsquic_packet_out;
1750aadb33SDmitri Tikhonovstruct parse_funcs;
1850aadb33SDmitri Tikhonovstruct stream_frame;
1950aadb33SDmitri Tikhonovstruct uncompressed_headers;
2050aadb33SDmitri Tikhonov
2150aadb33SDmitri Tikhonov
2250aadb33SDmitri Tikhonov/* Log a generic event not tied to any particular connection */
23b93f59beSBob Perper#define EV_LOG_GENERIC_EVENT(...) do {                                      \
2450aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
25b93f59beSBob Perper        lsquic_logger_log1(LSQ_LOG_DEBUG, LSQLM_EVENT, __VA_ARGS__);        \
2650aadb33SDmitri Tikhonov} while (0)
2750aadb33SDmitri Tikhonov
2850aadb33SDmitri Tikhonov/* Log a generic event associated with connection `cid' */
29b93f59beSBob Perper#define EV_LOG_CONN_EVENT(cid, ...) do {                                    \
3050aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
31b93f59beSBob Perper        lsquic_logger_log2(LSQ_LOG_DEBUG, LSQLM_EVENT, cid, __VA_ARGS__);   \
3250aadb33SDmitri Tikhonov} while (0)
3350aadb33SDmitri Tikhonov
3450aadb33SDmitri Tikhonovvoid
3550aadb33SDmitri Tikhonovlsquic_ev_log_packet_in (lsquic_cid_t, const struct lsquic_packet_in *);
3650aadb33SDmitri Tikhonov
37b93f59beSBob Perper#define EV_LOG_PACKET_IN(...) do {                                          \
3850aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
39b93f59beSBob Perper        lsquic_ev_log_packet_in(__VA_ARGS__);                               \
4050aadb33SDmitri Tikhonov} while (0)
4150aadb33SDmitri Tikhonov
4250aadb33SDmitri Tikhonovvoid
4350aadb33SDmitri Tikhonovlsquic_ev_log_ack_frame_in (lsquic_cid_t, const struct ack_info *);
4450aadb33SDmitri Tikhonov
45b93f59beSBob Perper#define EV_LOG_ACK_FRAME_IN(...) do {                                       \
4650aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
47b93f59beSBob Perper        lsquic_ev_log_ack_frame_in(__VA_ARGS__);                            \
4850aadb33SDmitri Tikhonov} while (0)
4950aadb33SDmitri Tikhonov
5050aadb33SDmitri Tikhonovvoid
5150aadb33SDmitri Tikhonovlsquic_ev_log_stream_frame_in (lsquic_cid_t, const struct stream_frame *);
5250aadb33SDmitri Tikhonov
53b93f59beSBob Perper#define EV_LOG_STREAM_FRAME_IN(...) do {                                    \
5450aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
55b93f59beSBob Perper        lsquic_ev_log_stream_frame_in(__VA_ARGS__);                         \
5650aadb33SDmitri Tikhonov} while (0)
5750aadb33SDmitri Tikhonov
5850aadb33SDmitri Tikhonovvoid
5950aadb33SDmitri Tikhonovlsquic_ev_log_window_update_frame_in (lsquic_cid_t, uint32_t stream_id,
6050aadb33SDmitri Tikhonov                                                            uint64_t offset);
6150aadb33SDmitri Tikhonov
62b93f59beSBob Perper#define EV_LOG_WINDOW_UPDATE_FRAME_IN(...) do {                             \
6350aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
64b93f59beSBob Perper        lsquic_ev_log_window_update_frame_in(__VA_ARGS__);                  \
6550aadb33SDmitri Tikhonov} while (0)
6650aadb33SDmitri Tikhonov
6750aadb33SDmitri Tikhonovvoid
6850aadb33SDmitri Tikhonovlsquic_ev_log_blocked_frame_in (lsquic_cid_t, uint32_t stream_id);
6950aadb33SDmitri Tikhonov
70b93f59beSBob Perper#define EV_LOG_BLOCKED_FRAME_IN(...) do {                                   \
7150aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
72b93f59beSBob Perper        lsquic_ev_log_blocked_frame_in(__VA_ARGS__);                        \
7350aadb33SDmitri Tikhonov} while (0)
7450aadb33SDmitri Tikhonov
7550aadb33SDmitri Tikhonovvoid
7650aadb33SDmitri Tikhonovlsquic_ev_log_stop_waiting_frame_in (lsquic_cid_t, lsquic_packno_t);
7750aadb33SDmitri Tikhonov
78b93f59beSBob Perper#define EV_LOG_STOP_WAITING_FRAME_IN(...) do {                              \
7950aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
80b93f59beSBob Perper        lsquic_ev_log_stop_waiting_frame_in(__VA_ARGS__);                   \
8150aadb33SDmitri Tikhonov} while (0)
8250aadb33SDmitri Tikhonov
8350aadb33SDmitri Tikhonovvoid
8450aadb33SDmitri Tikhonovlsquic_ev_log_connection_close_frame_in (lsquic_cid_t, uint32_t error_code,
8550aadb33SDmitri Tikhonov                                        int reason_len, const char *reason);
8650aadb33SDmitri Tikhonov
87b93f59beSBob Perper#define EV_LOG_CONNECTION_CLOSE_FRAME_IN(...) do {                          \
8850aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
89b93f59beSBob Perper        lsquic_ev_log_connection_close_frame_in(__VA_ARGS__);               \
9050aadb33SDmitri Tikhonov} while (0)
9150aadb33SDmitri Tikhonov
9250aadb33SDmitri Tikhonovvoid
9350aadb33SDmitri Tikhonovlsquic_ev_log_goaway_frame_in (lsquic_cid_t, uint32_t error_code,
9450aadb33SDmitri Tikhonov                uint32_t stream_id, int reason_len, const char *reason);
9550aadb33SDmitri Tikhonov
96b93f59beSBob Perper#define EV_LOG_GOAWAY_FRAME_IN(...) do {                                    \
9750aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
98b93f59beSBob Perper        lsquic_ev_log_goaway_frame_in(__VA_ARGS__);                         \
9950aadb33SDmitri Tikhonov} while (0)
10050aadb33SDmitri Tikhonov
10150aadb33SDmitri Tikhonovvoid
10250aadb33SDmitri Tikhonovlsquic_ev_log_rst_stream_frame_in (lsquic_cid_t, uint32_t stream_id,
10350aadb33SDmitri Tikhonov                                        uint64_t offset, uint32_t error_code);
10450aadb33SDmitri Tikhonov
105b93f59beSBob Perper#define EV_LOG_RST_STREAM_FRAME_IN(...) do {                                \
10650aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
107b93f59beSBob Perper        lsquic_ev_log_rst_stream_frame_in(__VA_ARGS__);                     \
10850aadb33SDmitri Tikhonov} while (0)
10950aadb33SDmitri Tikhonov
11050aadb33SDmitri Tikhonovvoid
11150aadb33SDmitri Tikhonovlsquic_ev_log_padding_frame_in (lsquic_cid_t, size_t len);
11250aadb33SDmitri Tikhonov
113b93f59beSBob Perper#define EV_LOG_PADDING_FRAME_IN(...) do {                                   \
11450aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
115b93f59beSBob Perper        lsquic_ev_log_padding_frame_in(__VA_ARGS__);                        \
11650aadb33SDmitri Tikhonov} while (0)
11750aadb33SDmitri Tikhonov
11850aadb33SDmitri Tikhonovvoid
11950aadb33SDmitri Tikhonovlsquic_ev_log_ping_frame_in (lsquic_cid_t);
12050aadb33SDmitri Tikhonov
121b93f59beSBob Perper#define EV_LOG_PING_FRAME_IN(...) do {                                      \
12250aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
123b93f59beSBob Perper        lsquic_ev_log_ping_frame_in(__VA_ARGS__);                           \
12450aadb33SDmitri Tikhonov} while (0)
12550aadb33SDmitri Tikhonov
12650aadb33SDmitri Tikhonovvoid
12750aadb33SDmitri Tikhonovlsquic_ev_log_packet_created (lsquic_cid_t, const struct lsquic_packet_out *);
12850aadb33SDmitri Tikhonov
129b93f59beSBob Perper#define EV_LOG_PACKET_CREATED(...) do {                                     \
13050aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
131b93f59beSBob Perper        lsquic_ev_log_packet_created(__VA_ARGS__);                          \
13250aadb33SDmitri Tikhonov} while (0)
13350aadb33SDmitri Tikhonov
13450aadb33SDmitri Tikhonovvoid
13550aadb33SDmitri Tikhonovlsquic_ev_log_packet_sent (lsquic_cid_t, const struct lsquic_packet_out *);
13650aadb33SDmitri Tikhonov
137b93f59beSBob Perper#define EV_LOG_PACKET_SENT(...) do {                                        \
13850aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
139b93f59beSBob Perper        lsquic_ev_log_packet_sent(__VA_ARGS__);                             \
14050aadb33SDmitri Tikhonov} while (0)
14150aadb33SDmitri Tikhonov
14250aadb33SDmitri Tikhonovvoid
14350aadb33SDmitri Tikhonovlsquic_ev_log_packet_not_sent (lsquic_cid_t, const struct lsquic_packet_out *);
14450aadb33SDmitri Tikhonov
145b93f59beSBob Perper#define EV_LOG_PACKET_NOT_SENT(...) do {                                    \
14650aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
147b93f59beSBob Perper        lsquic_ev_log_packet_not_sent(__VA_ARGS__);                         \
14850aadb33SDmitri Tikhonov} while (0)
14950aadb33SDmitri Tikhonov
15050aadb33SDmitri Tikhonovvoid
15150aadb33SDmitri Tikhonovlsquic_ev_log_http_headers_in (lsquic_cid_t, int is_server,
15250aadb33SDmitri Tikhonov                                        const struct uncompressed_headers *);
15350aadb33SDmitri Tikhonov
154b93f59beSBob Perper#define EV_LOG_HTTP_HEADERS_IN(...) do {                                    \
15550aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
156b93f59beSBob Perper        lsquic_ev_log_http_headers_in(__VA_ARGS__);                         \
15750aadb33SDmitri Tikhonov} while (0)
15850aadb33SDmitri Tikhonov
15950aadb33SDmitri Tikhonovvoid
160c51ce338SDmitri Tikhonovlsquic_ev_log_action_stream_frame (lsquic_cid_t, const struct parse_funcs *pf,
161c51ce338SDmitri Tikhonov                       const unsigned char *, size_t len, const char *action);
16250aadb33SDmitri Tikhonov
163b93f59beSBob Perper#define EV_LOG_GENERATED_STREAM_FRAME(...) do {                             \
16450aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
165b93f59beSBob Perper        lsquic_ev_log_action_stream_frame(__VA_ARGS__, "generated");        \
166c51ce338SDmitri Tikhonov} while (0)
167c51ce338SDmitri Tikhonov
168b93f59beSBob Perper#define EV_LOG_UPDATED_STREAM_FRAME(...) do {                               \
169c51ce338SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
170b93f59beSBob Perper        lsquic_ev_log_action_stream_frame(__VA_ARGS__, "updated");          \
17150aadb33SDmitri Tikhonov} while (0)
17250aadb33SDmitri Tikhonov
17350aadb33SDmitri Tikhonovvoid
17450aadb33SDmitri Tikhonovlsquic_ev_log_generated_ack_frame (lsquic_cid_t, const struct parse_funcs *,
17550aadb33SDmitri Tikhonov                                            const unsigned char *, size_t len);
17650aadb33SDmitri Tikhonov
177b93f59beSBob Perper#define EV_LOG_GENERATED_ACK_FRAME(...) do {                                \
17850aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
179b93f59beSBob Perper        lsquic_ev_log_generated_ack_frame(__VA_ARGS__);                     \
18050aadb33SDmitri Tikhonov} while (0)
18150aadb33SDmitri Tikhonov
18250aadb33SDmitri Tikhonovvoid
18350aadb33SDmitri Tikhonovlsquic_ev_log_generated_stop_waiting_frame (lsquic_cid_t, lsquic_packno_t);
18450aadb33SDmitri Tikhonov
185b93f59beSBob Perper#define EV_LOG_GENERATED_STOP_WAITING_FRAME(...) do {                       \
18650aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
187b93f59beSBob Perper        lsquic_ev_log_generated_stop_waiting_frame(__VA_ARGS__);            \
18850aadb33SDmitri Tikhonov} while (0)
18950aadb33SDmitri Tikhonov
19050aadb33SDmitri Tikhonovvoid
19150aadb33SDmitri Tikhonovlsquic_ev_log_generated_http_headers (lsquic_cid_t, uint32_t stream_id,
19250aadb33SDmitri Tikhonov                            int is_server, const struct http_prio_frame *,
19350aadb33SDmitri Tikhonov                            const struct lsquic_http_headers *);
19450aadb33SDmitri Tikhonov
19550aadb33SDmitri Tikhonov
196b93f59beSBob Perper#define EV_LOG_GENERATED_HTTP_HEADERS(...) do {                             \
19750aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
198b93f59beSBob Perper        lsquic_ev_log_generated_http_headers(__VA_ARGS__);                  \
19950aadb33SDmitri Tikhonov} while (0)
20050aadb33SDmitri Tikhonov
20150aadb33SDmitri Tikhonovvoid
20250aadb33SDmitri Tikhonovlsquic_ev_log_generated_http_push_promise (lsquic_cid_t, uint32_t stream_id,
20350aadb33SDmitri Tikhonov                            uint32_t promised_stream_id,
20450aadb33SDmitri Tikhonov                            const struct lsquic_http_headers *headers,
20550aadb33SDmitri Tikhonov                            const struct lsquic_http_headers *extra_headers);
20650aadb33SDmitri Tikhonov
207b93f59beSBob Perper#define EV_LOG_GENERATED_HTTP_PUSH_PROMISE(...) do {                        \
20850aadb33SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
209b93f59beSBob Perper        lsquic_ev_log_generated_http_push_promise(__VA_ARGS__);             \
21050aadb33SDmitri Tikhonov} while (0)
21150aadb33SDmitri Tikhonov
21255cd0b38SDmitri Tikhonovvoid
21355cd0b38SDmitri Tikhonovlsquic_ev_log_create_connection (lsquic_cid_t, const struct sockaddr *,
21455cd0b38SDmitri Tikhonov                                                    const struct sockaddr *);
21555cd0b38SDmitri Tikhonov
21655cd0b38SDmitri Tikhonov#define EV_LOG_CREATE_CONN(...) do {                                        \
21755cd0b38SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
21855cd0b38SDmitri Tikhonov        lsquic_ev_log_create_connection(__VA_ARGS__);                       \
21955cd0b38SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG))                     \
22055cd0b38SDmitri Tikhonov        lsquic_qlog_create_connection(__VA_ARGS__);                         \
22155cd0b38SDmitri Tikhonov} while (0)
22255cd0b38SDmitri Tikhonov
22355cd0b38SDmitri Tikhonovvoid
22455cd0b38SDmitri Tikhonovlsquic_ev_log_hsk_completed (lsquic_cid_t);
22555cd0b38SDmitri Tikhonov
22655cd0b38SDmitri Tikhonov#define EV_LOG_HSK_COMPLETED(...) do {                                      \
22755cd0b38SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
22855cd0b38SDmitri Tikhonov        lsquic_ev_log_hsk_completed(__VA_ARGS__);                           \
22955cd0b38SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG))                     \
23055cd0b38SDmitri Tikhonov        lsquic_qlog_hsk_completed(__VA_ARGS__);                             \
23155cd0b38SDmitri Tikhonov} while (0)
23255cd0b38SDmitri Tikhonov
23355cd0b38SDmitri Tikhonov
23455cd0b38SDmitri Tikhonovvoid
23555cd0b38SDmitri Tikhonovlsquic_ev_log_zero_rtt (lsquic_cid_t);
23655cd0b38SDmitri Tikhonov
23755cd0b38SDmitri Tikhonov#define EV_LOG_ZERO_RTT(...) do {                                           \
23855cd0b38SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
23955cd0b38SDmitri Tikhonov        lsquic_ev_log_zero_rtt(__VA_ARGS__);                                \
24055cd0b38SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG))                     \
24155cd0b38SDmitri Tikhonov        lsquic_qlog_zero_rtt(__VA_ARGS__);                                  \
24255cd0b38SDmitri Tikhonov} while (0)
24355cd0b38SDmitri Tikhonov
24455cd0b38SDmitri Tikhonovvoid
24555cd0b38SDmitri Tikhonovlsquic_ev_log_check_certs (lsquic_cid_t, const lsquic_str_t **, size_t);
24655cd0b38SDmitri Tikhonov
24755cd0b38SDmitri Tikhonov#define EV_LOG_CHECK_CERTS(...) do {                                        \
24855cd0b38SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
24955cd0b38SDmitri Tikhonov        lsquic_ev_log_check_certs(__VA_ARGS__);                             \
25055cd0b38SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG))                     \
25155cd0b38SDmitri Tikhonov        lsquic_qlog_check_certs(__VA_ARGS__);                               \
25255cd0b38SDmitri Tikhonov} while (0)
25355cd0b38SDmitri Tikhonov
25455cd0b38SDmitri Tikhonovvoid
25555cd0b38SDmitri Tikhonovlsquic_ev_log_version_negotiation (lsquic_cid_t, const char *, const char *);
25655cd0b38SDmitri Tikhonov
25755cd0b38SDmitri Tikhonov#define EV_LOG_VER_NEG(...) do {                                            \
25855cd0b38SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT))                    \
25955cd0b38SDmitri Tikhonov        lsquic_ev_log_version_negotiation(__VA_ARGS__);                     \
26055cd0b38SDmitri Tikhonov    if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_QLOG))                     \
26155cd0b38SDmitri Tikhonov        lsquic_qlog_version_negotiation(__VA_ARGS__);                       \
26255cd0b38SDmitri Tikhonov} while (0)
26355cd0b38SDmitri Tikhonov
26450aadb33SDmitri Tikhonov#endif
265