17#define htonll(x) ((1==htonl(1)) ? (x) : ((guint64)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32))
20#define ntohll(x) ((1==ntohl(1)) ? (x) : ((guint64)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32))
24#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
25#define BYTE_TO_BINARY(byte) \
26 ((byte) & 0x80 ? '1' : '0'), \
27 ((byte) & 0x40 ? '1' : '0'), \
28 ((byte) & 0x20 ? '1' : '0'), \
29 ((byte) & 0x10 ? '1' : '0'), \
30 ((byte) & 0x08 ? '1' : '0'), \
31 ((byte) & 0x04 ? '1' : '0'), \
32 ((byte) & 0x02 ? '1' : '0'), \
33 ((byte) & 0x01 ? '1' : '0')
43size_t imquic_strlcat(
char *dest,
const char *src,
size_t dest_size);
Bitstream abstraction.
Definition utils.h:166
size_t offset
Current position in the bitstream, in bits.
Definition utils.h:172
uint8_t * buffer
Buffer containing the data.
Definition utils.h:168
size_t size
Size of the buffer in bits.
Definition utils.h:170
Generic fixed size data buffer.
Definition utils.h:154
size_t length
Data length.
Definition utils.h:158
uint8_t buffer[1500]
Fixed size data buffer.
Definition utils.h:156
Generic data buffer.
Definition utils.h:133
size_t length
Data length.
Definition utils.h:137
uint8_t * buffer
Data buffer.
Definition utils.h:135
imquic_data * imquic_data_create(uint8_t *buffer, size_t length)
Helper method to create a data buffer out of existing data.
Definition utils.c:228
int imquic_strlcat_fast(char *dest, const char *src, size_t dest_size, size_t *offset)
Alternative helper method to concatenate strings and log an error if truncation occurred,...
Definition utils.c:26
size_t imquic_strlcat(char *dest, const char *src, size_t dest_size)
Helper method to concatenate strings and log an error if truncation occurred.
Definition utils.c:19
uint64_t imquic_random_uint64(void)
Helper to generate random 64 bit unsigned integers.
Definition utils.c:48
uint64_t imquic_read_varint(uint8_t *bytes, size_t blen, uint8_t *length)
Read a variable size integer from a buffer.
Definition utils.c:64
struct imquic_data imquic_data
Generic data buffer.
uint8_t imquic_write_varint(uint64_t number, uint8_t *bytes, size_t blen)
Write a variable size integer to a buffer.
Definition utils.c:82
void imquic_data_destroy(imquic_data *data)
Helper method to free an existing data buffer.
Definition utils.c:255
uint8_t imquic_bitstream_peek(imquic_bitstream *bs, uint8_t *len)
Helper method to peek 8 bit in the bitstream.
Definition utils.c:263
void imquic_print_hex(int level, uint8_t *buf, size_t buflen)
Helper method mostly used for debugging: prints the content of a hex buffer.
Definition utils.c:220
struct imquic_data_fixed imquic_data_fixed
Generic fixed size data buffer.
uint64_t * imquic_dup_uint64(uint64_t num)
Helper to generate an allocated copy of a uint64_t number.
Definition utils.c:57
size_t imquic_bitstream_write(imquic_bitstream *bs, uint32_t value, uint8_t bits)
Helper method to add bits to a bitstream buffer.
Definition utils.c:288
uint8_t imquic_write_pfxint(uint64_t number, uint8_t n, uint8_t *bytes, size_t blen)
Write a prefixed integer to a buffer (QPACK only)
Definition utils.c:160
uint64_t imquic_read_pfxint(uint8_t n, uint8_t *bytes, size_t blen, uint8_t *length)
Read a prefixed integer from a buffer (QPACK only)
Definition utils.c:128
struct imquic_bitstream imquic_bitstream
Bitstream abstraction.
uint64_t imquic_full_packet_number(uint64_t largest, uint64_t pn_pkt, uint8_t p_len)
Helper method to reconstruct a full QUIC packet number.
Definition utils.c:193
gboolean imquic_data_equal(const void *a, const void *b)
Helper comparator function, to check if two buffers contain the same data.
Definition utils.c:242