Loading...
Searching...
No Matches
qlog.h
Go to the documentation of this file.
1
16#ifndef IMQUIC_QLOG_H
17#define IMQUIC_QLOG_H
18
19#include <glib.h>
20
23gboolean imquic_qlog_is_supported(void);
24
25#ifdef HAVE_QLOG
26#include <jansson.h>
27
28#include "refcount.h"
29#include "mutex.h"
30
34
35#define IMQUIC_QLOG_TRIGGER_INTERNAL_ERROR "internal_error"
36#define IMQUIC_QLOG_TRIGGER_REJECTED "rejected"
37#define IMQUIC_QLOG_TRIGGER_UNSUPPORTED "unsupported"
38#define IMQUIC_QLOG_TRIGGER_INVALID "invalid"
39#define IMQUIC_QLOG_TRIGGER_DUPLICATE "duplicate"
40#define IMQUIC_QLOG_TRIGGER_CONNECTION_UNKNOWN "connection_unknown"
41#define IMQUIC_QLOG_TRIGGER_DECRYPTION_FAILURE "decryption_failure"
42#define IMQUIC_QLOG_TRIGGER_KEY_UNAVAILABLE "key_unavailable"
43#define IMQUIC_QLOG_TRIGGER_GENERAL "general"
45
49
50typedef struct imquic_qlog {
52 char *id;
54 gboolean sequential;
56 gboolean is_server;
58 gboolean quic, http3, roq, moq;
60 json_t *root;
62 json_t *common;
64 json_t *events;
66 char *filename;
68 FILE *file;
72 volatile gint destroyed;
76
92imquic_qlog *imquic_qlog_create(char *id, gboolean sequential, gboolean is_server,
93 char *filename, gboolean quic, gboolean http3, gboolean roq, gboolean moq);
97void imquic_qlog_set_odcid(imquic_qlog *qlog, void *odcid);
109
113
117json_t *imquic_qlog_event_prepare(const char *name);
121json_t *imquic_qlog_event_add_data(json_t *event);
127void imquic_qlog_event_add_raw(json_t *parent, const char *name, uint8_t *bytes, size_t length);
134void imquic_qlog_event_add_path_endpoint_info(json_t *parent, const char *name, const char *ip, uint16_t port);
138void imquic_qlog_append_event(imquic_qlog *qlog, json_t *event);
145void imquic_qlog_connection_started(imquic_qlog *qlog, const char *local_ip, uint16_t local_port, const char *remote_ip, uint16_t remote_port);
152void imquic_qlog_connection_closed(imquic_qlog *qlog, gboolean local, uint32_t cc_code, uint32_t app_code, const char *reason);
157void imquic_qlog_version_information(imquic_qlog *qlog, uint32_t version, uint32_t chosen);
165void imquic_qlog_alpn_information(imquic_qlog *qlog, uint8_t *server_alpn, size_t server_alpn_len,
166 uint8_t *client_alpn, size_t client_alpn_len, char *chosen);
175json_t *imquic_qlog_prepare_parameters_set(imquic_qlog *qlog, gboolean local, gboolean resumption, gboolean early_data);
179void imquic_qlog_parameters_set(imquic_qlog *qlog, json_t *params);
187json_t *imquic_qlog_prepare_packet_header(const char *type, void *scid, void *dcid);
193json_t *imquic_qlog_prepare_packet_frame(const char *type);
200void imquic_qlog_packet_sent(imquic_qlog *qlog, json_t *header, json_t *frames, uint32_t id, size_t length);
207void imquic_qlog_packet_received(imquic_qlog *qlog, json_t *header, json_t *frames, uint32_t id, size_t length);
214void imquic_qlog_packet_dropped(imquic_qlog *qlog, json_t *header, uint32_t id, size_t length, const char *trigger);
219void imquic_qlog_udp_datagrams_sent(imquic_qlog *qlog, uint32_t id, size_t length);
224void imquic_qlog_udp_datagrams_received(imquic_qlog *qlog, uint32_t id, size_t length);
229void imquic_qlog_udp_datagrams_dropped(imquic_qlog *qlog, uint32_t id, size_t length);
236void imquic_qlog_stream_state_updated(imquic_qlog *qlog, uint64_t id, const char *type, const char *side, const char *state);
243void imquic_qlog_key_updated(imquic_qlog *qlog, const char *type, uint8_t *key, size_t key_len, uint64_t key_phase);
245
246#endif
247
248#endif
Semaphores, Mutexes and Conditions.
GMutex imquic_mutex
imquic mutex implementation
Definition mutex.h:18
void imquic_qlog_connection_closed(imquic_qlog *qlog, gboolean local, uint32_t cc_code, uint32_t app_code, const char *reason)
Add a connection_closed event.
Definition qlog.c:316
struct imquic_qlog imquic_qlog
QLOG instance.
json_t * imquic_qlog_prepare_packet_header(const char *type, void *scid, void *dcid)
Prepare a header object, but don't add it yet.
Definition qlog.c:413
void imquic_qlog_alpn_information(imquic_qlog *qlog, uint8_t *server_alpn, size_t server_alpn_len, uint8_t *client_alpn, size_t client_alpn_len, char *chosen)
Add a alpn_information event.
Definition qlog.c:345
json_t * imquic_qlog_prepare_packet_frame(const char *type)
Prepare a frames object, but don't add it yet.
Definition qlog.c:440
int imquic_qlog_save_to_file(imquic_qlog *qlog)
Save the current status of the QLOG structure to JSON.
Definition qlog.c:160
void imquic_qlog_append_event(imquic_qlog *qlog, json_t *event)
Helper to add a complete event object to an existing QLOG instance.
Definition qlog.c:260
void imquic_qlog_event_add_path_endpoint_info(json_t *parent, const char *name, const char *ip, uint16_t port)
Helper to add/append a PathEndpointInfo object to the specified object or array.
Definition qlog.c:238
void imquic_qlog_version_information(imquic_qlog *qlog, uint32_t version, uint32_t chosen)
Add a version_information event.
Definition qlog.c:332
json_t * imquic_qlog_event_add_data(json_t *event)
Helper to add a data object to an event and return a pointer to it.
Definition qlog.c:212
json_t * imquic_qlog_event_prepare(const char *name)
Helper to create a new QLOG event by name.
Definition qlog.c:204
void imquic_qlog_packet_dropped(imquic_qlog *qlog, json_t *header, uint32_t id, size_t length, const char *trigger)
Add a packet_dropped event.
Definition qlog.c:488
void imquic_qlog_event_add_raw(json_t *parent, const char *name, uint8_t *bytes, size_t length)
Helper to add/append a raw object to the specified object or array.
Definition qlog.c:220
imquic_qlog * imquic_qlog_create(char *id, gboolean sequential, gboolean is_server, char *filename, gboolean quic, gboolean http3, gboolean roq, gboolean moq)
Helper method to initialize a new QLOG instance.
Definition qlog.c:51
void imquic_qlog_stream_state_updated(imquic_qlog *qlog, uint64_t id, const char *type, const char *side, const char *state)
Add a stream_state_updated event.
Definition qlog.c:546
void imquic_qlog_udp_datagrams_received(imquic_qlog *qlog, uint32_t id, size_t length)
Add a udp_datagrams_received event.
Definition qlog.c:521
void imquic_qlog_destroy(imquic_qlog *qlog)
Helper method to destroy an existing QLOG instance.
Definition qlog.c:149
void imquic_qlog_udp_datagrams_dropped(imquic_qlog *qlog, uint32_t id, size_t length)
Add a udp_datagrams_dropped event.
Definition qlog.c:535
void imquic_qlog_udp_datagrams_sent(imquic_qlog *qlog, uint32_t id, size_t length)
Add a udp_datagrams_sent event.
Definition qlog.c:507
void imquic_qlog_set_odcid(imquic_qlog *qlog, void *odcid)
Set/update the Original Destination Connection ID.
Definition qlog.c:139
gboolean imquic_qlog_is_supported(void)
Helper method to check if QLOG is supported at runtime.
Definition qlog.c:28
void imquic_qlog_packet_received(imquic_qlog *qlog, json_t *header, json_t *frames, uint32_t id, size_t length)
Add a packet_received event.
Definition qlog.c:468
void imquic_qlog_packet_sent(imquic_qlog *qlog, json_t *header, json_t *frames, uint32_t id, size_t length)
Add a packet_sent event.
Definition qlog.c:448
json_t * imquic_qlog_prepare_parameters_set(imquic_qlog *qlog, gboolean local, gboolean resumption, gboolean early_data)
Prepare a parameters_set object, but don't add it yet.
Definition qlog.c:390
void imquic_qlog_parameters_set(imquic_qlog *qlog, json_t *params)
Add a parameters_set event.
Definition qlog.c:402
void imquic_qlog_key_updated(imquic_qlog *qlog, const char *type, uint8_t *key, size_t key_len, uint64_t key_phase)
Add a key_updated event.
Definition qlog.c:561
void imquic_qlog_connection_started(imquic_qlog *qlog, const char *local_ip, uint16_t local_port, const char *remote_ip, uint16_t remote_port)
Add a connection_started event.
Definition qlog.c:306
Reference counter mechanism.
QLOG instance.
Definition qlog.h:50
gboolean is_server
Whether this is for a client or server connection.
Definition qlog.h:56
gboolean quic
Whether QUIC and/or HTTP/3 and/or RoQ and/or MoQT events should be saved.
Definition qlog.h:58
json_t * root
Jansson JSON instance.
Definition qlog.h:60
FILE * file
File to save the JSON file to.
Definition qlog.h:68
imquic_mutex mutex
Mutex.
Definition qlog.h:70
imquic_refcount ref
Reference counter.
Definition qlog.h:74
gboolean http3
Definition qlog.h:58
volatile gint destroyed
Whether this instance has been destroyed (reference counting)
Definition qlog.h:72
char * filename
Path to where the JSON file should be saved.
Definition qlog.h:66
json_t * common
Reference to the common fields entry.
Definition qlog.h:62
gboolean sequential
Whether sequential JSON will be used, instead of regular JSON.
Definition qlog.h:54
char * id
Instance ID.
Definition qlog.h:52
gboolean roq
Definition qlog.h:58
gboolean moq
Definition qlog.h:58
json_t * events
Reference to the events array.
Definition qlog.h:64
Definition refcount.h:77