Initial PlusWindows commit

This commit is contained in:
Bob Perper 2018-03-30 10:57:17 -04:00
parent 00ee28ce61
commit b93f59bea2
28 changed files with 722 additions and 465 deletions

View file

@ -445,7 +445,7 @@ int decompress_certs(const unsigned char *in, const unsigned char *in_end,
{
int ret;
size_t i;
uint8_t* uncompressed_data = NULL, *uncompressed_data_buf = NULL;
uint8_t* uncompressed_data, *uncompressed_data_buf;
lsquic_str_t *dict;
uint32_t uncompressed_size;
size_t count = *out_certs_count;
@ -463,6 +463,9 @@ int decompress_certs(const unsigned char *in, const unsigned char *in_end,
return -1;
uncompressed_data_buf = NULL;
#ifdef WIN32
uncompressed_data = NULL;
#endif
entries = malloc(count * sizeof(cert_entry_t));
if (!entries)
goto err;
@ -487,6 +490,9 @@ int decompress_certs(const unsigned char *in, const unsigned char *in_end,
goto err;
uncompressed_data_buf = uncompressed_data = malloc(uncompressed_size);
if (!uncompressed_data)
goto err;
memset(&z, 0, sizeof(z));
z.next_out = uncompressed_data;
z.avail_out = uncompressed_size;

View file

@ -16,10 +16,14 @@
#include "lsquic_data_in_if.h"
static const struct data_in *error_data_in_ptr;
struct data_in *
data_in_error_new (struct lsquic_conn_public *conn_pub)
{
return (struct data_in *) error_data_in_ptr;
}
static void
@ -80,12 +84,12 @@ static const struct data_in_iface di_if_error = {
.di_mem_used = error_di_mem_used,
.di_switch_impl = error_di_switch_impl,
};
static const struct data_in error_data_in = {
.di_if = &di_if_error,
.di_flags = 0,
};
struct data_in *
data_in_error_new (struct lsquic_conn_public *conn_pub)
{
return (struct data_in *) &error_data_in;
}
static const struct data_in *error_data_in_ptr = &error_data_in;

View file

@ -61,6 +61,7 @@ typedef char db_block_is_4K[(sizeof(struct data_block) == 0x1000) ?1:- 1];
TAILQ_HEAD(dblock_head, data_block);
static const struct data_in_iface *di_if_hash_ptr;
struct hash_data_in
@ -108,6 +109,43 @@ my_log2 /* silly name to suppress compiler warning */ (unsigned sz)
}
struct data_in *
data_in_hash_new (struct lsquic_conn_public *conn_pub, uint32_t stream_id,
uint64_t byteage)
{
struct hash_data_in *hdi;
unsigned n;
hdi = malloc(sizeof(*hdi));
if (!hdi)
return NULL;
hdi->hdi_data_in.di_if = di_if_hash_ptr;
hdi->hdi_data_in.di_flags = 0;
hdi->hdi_conn_pub = conn_pub;
hdi->hdi_stream_id = stream_id;
hdi->hdi_fin_off = 0;
hdi->hdi_flags = 0;
hdi->hdi_last_block = NULL;
if (byteage >= DB_DATA_SIZE /* __builtin_clz is undefined if
argument is 0 */)
hdi->hdi_nbits = my_log2(byteage / DB_DATA_SIZE) + 2;
else
hdi->hdi_nbits = 3;
hdi->hdi_count = 0;
hdi->hdi_buckets = malloc(sizeof(hdi->hdi_buckets[0]) *
N_BUCKETS(hdi->hdi_nbits));
if (!hdi->hdi_buckets)
{
free(hdi);
return NULL;
}
for (n = 0; n < N_BUCKETS(hdi->hdi_nbits); ++n)
TAILQ_INIT(&hdi->hdi_buckets[n]);
return &hdi->hdi_data_in;
}
static void
@ -599,40 +637,5 @@ static const struct data_in_iface di_if_hash = {
.di_mem_used = hash_di_mem_used,
.di_switch_impl = hash_di_switch_impl,
};
struct data_in *
data_in_hash_new (struct lsquic_conn_public *conn_pub, uint32_t stream_id,
uint64_t byteage)
{
struct hash_data_in *hdi;
unsigned n;
hdi = malloc(sizeof(*hdi));
if (!hdi)
return NULL;
hdi->hdi_data_in.di_if = &di_if_hash;
hdi->hdi_data_in.di_flags = 0;
hdi->hdi_conn_pub = conn_pub;
hdi->hdi_stream_id = stream_id;
hdi->hdi_fin_off = 0;
hdi->hdi_flags = 0;
hdi->hdi_last_block = NULL;
if (byteage >= DB_DATA_SIZE /* __builtin_clz is undefined if
argument is 0 */)
hdi->hdi_nbits = my_log2(byteage / DB_DATA_SIZE) + 2;
else
hdi->hdi_nbits = 3;
hdi->hdi_count = 0;
hdi->hdi_buckets = malloc(sizeof(hdi->hdi_buckets[0]) *
N_BUCKETS(hdi->hdi_nbits));
if (!hdi->hdi_buckets)
{
free(hdi);
return NULL;
}
for (n = 0; n < N_BUCKETS(hdi->hdi_nbits); ++n)
TAILQ_INIT(&hdi->hdi_buckets[n]);
return &hdi->hdi_data_in;
}
static const struct data_in_iface *di_if_hash_ptr = &di_if_hash;

View file

@ -116,8 +116,30 @@ struct nocopy_data_in
((unsigned char *) (data_frame) - offsetof(struct stream_frame, data_frame))
static const struct data_in_iface *di_if_nocopy_ptr;
struct data_in *
data_in_nocopy_new (struct lsquic_conn_public *conn_pub, uint32_t stream_id)
{
struct nocopy_data_in *ncdi;
ncdi = malloc(sizeof(*ncdi));
if (!ncdi)
return NULL;
TAILQ_INIT(&ncdi->ncdi_frames_in);
ncdi->ncdi_data_in.di_if = di_if_nocopy_ptr;
ncdi->ncdi_data_in.di_flags = 0;
ncdi->ncdi_conn_pub = conn_pub;
ncdi->ncdi_stream_id = stream_id;
ncdi->ncdi_byteage = 0;
ncdi->ncdi_n_frames = 0;
ncdi->ncdi_n_holes = 0;
ncdi->ncdi_cons_far = 0;
return &ncdi->ncdi_data_in;
}
static void
nocopy_di_destroy (struct data_in *data_in)
@ -422,24 +444,5 @@ static const struct data_in_iface di_if_nocopy = {
.di_mem_used = nocopy_di_mem_used,
.di_switch_impl = nocopy_di_switch_impl,
};
struct data_in *
data_in_nocopy_new (struct lsquic_conn_public *conn_pub, uint32_t stream_id)
{
struct nocopy_data_in *ncdi;
ncdi = malloc(sizeof(*ncdi));
if (!ncdi)
return NULL;
TAILQ_INIT(&ncdi->ncdi_frames_in);
ncdi->ncdi_data_in.di_if = &di_if_nocopy;
ncdi->ncdi_data_in.di_flags = 0;
ncdi->ncdi_conn_pub = conn_pub;
ncdi->ncdi_stream_id = stream_id;
ncdi->ncdi_byteage = 0;
ncdi->ncdi_n_frames = 0;
ncdi->ncdi_n_holes = 0;
ncdi->ncdi_cons_far = 0;
return &ncdi->ncdi_data_in;
}
static const struct data_in_iface *di_if_nocopy_ptr = &di_if_nocopy;

View file

@ -19,171 +19,171 @@ struct uncompressed_headers;
/* Log a generic event not tied to any particular connection */
#define EV_LOG_GENERIC_EVENT(...) do { \
#define EV_LOG_GENERIC_EVENT(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_logger_log1(LSQ_LOG_DEBUG, LSQLM_EVENT, __VA_ARGS__); \
lsquic_logger_log1(LSQ_LOG_DEBUG, LSQLM_EVENT, __VA_ARGS__); \
} while (0)
/* Log a generic event associated with connection `cid' */
#define EV_LOG_CONN_EVENT(cid, ...) do { \
#define EV_LOG_CONN_EVENT(cid, ...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_logger_log2(LSQ_LOG_DEBUG, LSQLM_EVENT, cid, __VA_ARGS__); \
lsquic_logger_log2(LSQ_LOG_DEBUG, LSQLM_EVENT, cid, __VA_ARGS__); \
} while (0)
void
lsquic_ev_log_packet_in (lsquic_cid_t, const struct lsquic_packet_in *);
#define EV_LOG_PACKET_IN(...) do { \
#define EV_LOG_PACKET_IN(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_packet_in(__VA_ARGS__); \
lsquic_ev_log_packet_in(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_ack_frame_in (lsquic_cid_t, const struct ack_info *);
#define EV_LOG_ACK_FRAME_IN(...) do { \
#define EV_LOG_ACK_FRAME_IN(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_ack_frame_in(__VA_ARGS__); \
lsquic_ev_log_ack_frame_in(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_stream_frame_in (lsquic_cid_t, const struct stream_frame *);
#define EV_LOG_STREAM_FRAME_IN(...) do { \
#define EV_LOG_STREAM_FRAME_IN(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_stream_frame_in(__VA_ARGS__); \
lsquic_ev_log_stream_frame_in(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_window_update_frame_in (lsquic_cid_t, uint32_t stream_id,
uint64_t offset);
#define EV_LOG_WINDOW_UPDATE_FRAME_IN(...) do { \
#define EV_LOG_WINDOW_UPDATE_FRAME_IN(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_window_update_frame_in(__VA_ARGS__); \
lsquic_ev_log_window_update_frame_in(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_blocked_frame_in (lsquic_cid_t, uint32_t stream_id);
#define EV_LOG_BLOCKED_FRAME_IN(...) do { \
#define EV_LOG_BLOCKED_FRAME_IN(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_blocked_frame_in(__VA_ARGS__); \
lsquic_ev_log_blocked_frame_in(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_stop_waiting_frame_in (lsquic_cid_t, lsquic_packno_t);
#define EV_LOG_STOP_WAITING_FRAME_IN(...) do { \
#define EV_LOG_STOP_WAITING_FRAME_IN(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_stop_waiting_frame_in(__VA_ARGS__); \
lsquic_ev_log_stop_waiting_frame_in(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_connection_close_frame_in (lsquic_cid_t, uint32_t error_code,
int reason_len, const char *reason);
#define EV_LOG_CONNECTION_CLOSE_FRAME_IN(...) do { \
#define EV_LOG_CONNECTION_CLOSE_FRAME_IN(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_connection_close_frame_in(__VA_ARGS__); \
lsquic_ev_log_connection_close_frame_in(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_goaway_frame_in (lsquic_cid_t, uint32_t error_code,
uint32_t stream_id, int reason_len, const char *reason);
#define EV_LOG_GOAWAY_FRAME_IN(...) do { \
#define EV_LOG_GOAWAY_FRAME_IN(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_goaway_frame_in(__VA_ARGS__); \
lsquic_ev_log_goaway_frame_in(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_rst_stream_frame_in (lsquic_cid_t, uint32_t stream_id,
uint64_t offset, uint32_t error_code);
#define EV_LOG_RST_STREAM_FRAME_IN(...) do { \
#define EV_LOG_RST_STREAM_FRAME_IN(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_rst_stream_frame_in(__VA_ARGS__); \
lsquic_ev_log_rst_stream_frame_in(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_padding_frame_in (lsquic_cid_t, size_t len);
#define EV_LOG_PADDING_FRAME_IN(...) do { \
#define EV_LOG_PADDING_FRAME_IN(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_padding_frame_in(__VA_ARGS__); \
lsquic_ev_log_padding_frame_in(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_ping_frame_in (lsquic_cid_t);
#define EV_LOG_PING_FRAME_IN(...) do { \
#define EV_LOG_PING_FRAME_IN(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_ping_frame_in(__VA_ARGS__); \
lsquic_ev_log_ping_frame_in(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_packet_created (lsquic_cid_t, const struct lsquic_packet_out *);
#define EV_LOG_PACKET_CREATED(...) do { \
#define EV_LOG_PACKET_CREATED(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_packet_created(__VA_ARGS__); \
lsquic_ev_log_packet_created(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_packet_sent (lsquic_cid_t, const struct lsquic_packet_out *);
#define EV_LOG_PACKET_SENT(...) do { \
#define EV_LOG_PACKET_SENT(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_packet_sent(__VA_ARGS__); \
lsquic_ev_log_packet_sent(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_packet_not_sent (lsquic_cid_t, const struct lsquic_packet_out *);
#define EV_LOG_PACKET_NOT_SENT(...) do { \
#define EV_LOG_PACKET_NOT_SENT(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_packet_not_sent(__VA_ARGS__); \
lsquic_ev_log_packet_not_sent(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_http_headers_in (lsquic_cid_t, int is_server,
const struct uncompressed_headers *);
#define EV_LOG_HTTP_HEADERS_IN(...) do { \
#define EV_LOG_HTTP_HEADERS_IN(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_http_headers_in(__VA_ARGS__); \
lsquic_ev_log_http_headers_in(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_action_stream_frame (lsquic_cid_t, const struct parse_funcs *pf,
const unsigned char *, size_t len, const char *action);
#define EV_LOG_GENERATED_STREAM_FRAME(...) do { \
#define EV_LOG_GENERATED_STREAM_FRAME(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_action_stream_frame(__VA_ARGS__, "generated"); \
lsquic_ev_log_action_stream_frame(__VA_ARGS__, "generated"); \
} while (0)
#define EV_LOG_UPDATED_STREAM_FRAME(...) do { \
#define EV_LOG_UPDATED_STREAM_FRAME(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_action_stream_frame(__VA_ARGS__, "updated"); \
lsquic_ev_log_action_stream_frame(__VA_ARGS__, "updated"); \
} while (0)
void
lsquic_ev_log_generated_ack_frame (lsquic_cid_t, const struct parse_funcs *,
const unsigned char *, size_t len);
#define EV_LOG_GENERATED_ACK_FRAME(...) do { \
#define EV_LOG_GENERATED_ACK_FRAME(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_generated_ack_frame(__VA_ARGS__); \
lsquic_ev_log_generated_ack_frame(__VA_ARGS__); \
} while (0)
void
lsquic_ev_log_generated_stop_waiting_frame (lsquic_cid_t, lsquic_packno_t);
#define EV_LOG_GENERATED_STOP_WAITING_FRAME(...) do { \
#define EV_LOG_GENERATED_STOP_WAITING_FRAME(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_generated_stop_waiting_frame(__VA_ARGS__); \
lsquic_ev_log_generated_stop_waiting_frame(__VA_ARGS__); \
} while (0)
void
@ -192,9 +192,9 @@ lsquic_ev_log_generated_http_headers (lsquic_cid_t, uint32_t stream_id,
const struct lsquic_http_headers *);
#define EV_LOG_GENERATED_HTTP_HEADERS(...) do { \
#define EV_LOG_GENERATED_HTTP_HEADERS(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_generated_http_headers(__VA_ARGS__); \
lsquic_ev_log_generated_http_headers(__VA_ARGS__); \
} while (0)
void
@ -203,9 +203,9 @@ lsquic_ev_log_generated_http_push_promise (lsquic_cid_t, uint32_t stream_id,
const struct lsquic_http_headers *headers,
const struct lsquic_http_headers *extra_headers);
#define EV_LOG_GENERATED_HTTP_PUSH_PROMISE(...) do { \
#define EV_LOG_GENERATED_HTTP_PUSH_PROMISE(...) do { \
if (LSQ_LOG_ENABLED_EXT(LSQ_LOG_DEBUG, LSQLM_EVENT)) \
lsquic_ev_log_generated_http_push_promise(__VA_ARGS__); \
lsquic_ev_log_generated_http_push_promise(__VA_ARGS__); \
} while (0)
#endif

View file

@ -648,8 +648,10 @@ add_pseudo_header_to_uh (const struct lsquic_frame_reader *fr,
}
#define HTTP_CODE_LEN 3
static const char *
code_str_to_reason (const char *code_str, int code_len)
code_str_to_reason (const char code_str[HTTP_CODE_LEN])
{
/* RFC 7231, Section 6: */
static const char *const http_reason_phrases[] =
@ -700,12 +702,11 @@ code_str_to_reason (const char *code_str, int code_len)
};
long code;
char * code_buf = malloc(code_len + 1 );
char code_buf[HTTP_CODE_LEN + 1];
strncpy(code_buf, code_str, code_len);
code_buf[code_len] = '\0';
memcpy(code_buf, code_str, HTTP_CODE_LEN);
code_buf[HTTP_CODE_LEN] = '\0';
code = strtol(code_buf, NULL, 10) - 100;
free(code_buf);
if (code > 0 && code < (long) (sizeof(http_reason_phrases) /
sizeof(http_reason_phrases[0])))
return http_reason_phrases[code];
@ -742,7 +743,7 @@ convert_response_pseudo_headers (const struct lsquic_frame_reader *fr,
HWC_UH_WRITE(hwc, "HTTP/1.1 ", 9);
HWC_UH_WRITE(hwc, code_str, code_len);
if (3 == code_len && (reason = code_str_to_reason(code_str, code_len)))
if (HTTP_CODE_LEN == code_len && (reason = code_str_to_reason(code_str)))
{
HWC_UH_WRITE(hwc, " ", 1);
HWC_UH_WRITE(hwc, reason, strlen(reason));

View file

@ -217,17 +217,17 @@ struct full_conn
#define MAX_ERRMSG 256
#define SET_ERRMSG(conn, ...) do { \
#define SET_ERRMSG(conn, ...) do { \
if (!(conn)->fc_errmsg) \
(conn)->fc_errmsg = malloc(MAX_ERRMSG); \
if ((conn)->fc_errmsg) \
snprintf((conn)->fc_errmsg, MAX_ERRMSG, __VA_ARGS__); \
snprintf((conn)->fc_errmsg, MAX_ERRMSG, __VA_ARGS__); \
} while (0)
#define ABORT_WITH_FLAG(conn, flag, ...) do { \
SET_ERRMSG(conn, __VA_ARGS__); \
#define ABORT_WITH_FLAG(conn, flag, ...) do { \
SET_ERRMSG(conn, __VA_ARGS__); \
(conn)->fc_flags |= flag; \
LSQ_ERROR("Abort connection: " __VA_ARGS__); \
LSQ_ERROR("Abort connection: " __VA_ARGS__); \
} while (0)
#define ABORT_ERROR(...) ABORT_WITH_FLAG(conn, FC_ERROR, __VA_ARGS__)
@ -258,6 +258,7 @@ write_is_possible (struct full_conn *);
static int
dispatch_stream_read_events (struct full_conn *, struct lsquic_stream *);
static const struct headers_stream_callbacks *headers_callbacks_ptr;
#if KEEP_CLOSED_STREAM_HISTORY
@ -520,9 +521,174 @@ apply_peer_settings (struct full_conn *conn)
}
static const struct conn_iface *full_conn_iface_ptr;
static struct full_conn *
new_conn_common (lsquic_cid_t cid, struct lsquic_engine_public *enpub,
const struct lsquic_stream_if *stream_if,
void *stream_if_ctx, unsigned flags,
unsigned short max_packet_size)
{
struct full_conn *conn;
lsquic_stream_t *headers_stream;
int saved_errno;
assert(0 == (flags & ~(FC_SERVER|FC_HTTP)));
conn = calloc(1, sizeof(*conn));
if (!conn)
return NULL;
headers_stream = NULL;
conn->fc_conn.cn_cid = cid;
conn->fc_conn.cn_pack_size = max_packet_size;
conn->fc_flags = flags;
conn->fc_enpub = enpub;
conn->fc_pub.enpub = enpub;
conn->fc_pub.mm = &enpub->enp_mm;
conn->fc_pub.lconn = &conn->fc_conn;
conn->fc_pub.send_ctl = &conn->fc_send_ctl;
conn->fc_pub.packet_out_malo =
lsquic_malo_create(sizeof(struct lsquic_packet_out));
conn->fc_stream_ifs[STREAM_IF_STD].stream_if = stream_if;
conn->fc_stream_ifs[STREAM_IF_STD].stream_if_ctx = stream_if_ctx;
conn->fc_settings = &enpub->enp_settings;
/* Calculate maximum number of incoming streams using the same mechanism
* and parameters as found in Chrome:
*/
conn->fc_cfg.max_streams_in =
(unsigned) ((float) enpub->enp_settings.es_max_streams_in * 1.1f);
if (conn->fc_cfg.max_streams_in <
enpub->enp_settings.es_max_streams_in + 10)
conn->fc_cfg.max_streams_in =
enpub->enp_settings.es_max_streams_in + 10;
/* `max_streams_out' gets reset when handshake is complete and we
* learn of peer settings. 100 seems like a sane default value
* because it is what other implementations use. In server mode,
* we do not open any streams until the handshake is complete; in
* client mode, we are limited to 98 outgoing requests alongside
* handshake and headers streams.
*/
conn->fc_cfg.max_streams_out = 100;
TAILQ_INIT(&conn->fc_pub.sending_streams);
TAILQ_INIT(&conn->fc_pub.read_streams);
TAILQ_INIT(&conn->fc_pub.write_streams);
TAILQ_INIT(&conn->fc_pub.service_streams);
STAILQ_INIT(&conn->fc_stream_ids_to_reset);
lsquic_conn_cap_init(&conn->fc_pub.conn_cap, LSQUIC_MIN_FCW);
lsquic_alarmset_init(&conn->fc_alset, cid);
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_IDLE, idle_alarm_expired, conn);
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_ACK, ack_alarm_expired, conn);
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_PING, ping_alarm_expired, conn);
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_HANDSHAKE, handshake_alarm_expired, conn);
lsquic_set32_init(&conn->fc_closed_stream_ids[0]);
lsquic_set32_init(&conn->fc_closed_stream_ids[1]);
lsquic_cfcw_init(&conn->fc_pub.cfcw, &conn->fc_pub, conn->fc_settings->es_cfcw);
lsquic_send_ctl_init(&conn->fc_send_ctl, &conn->fc_alset, conn->fc_enpub,
&conn->fc_ver_neg, &conn->fc_pub, conn->fc_conn.cn_pack_size);
conn->fc_pub.all_streams = lsquic_hash_create();
if (!conn->fc_pub.all_streams)
goto cleanup_on_error;
lsquic_rechist_init(&conn->fc_rechist, cid);
if (conn->fc_flags & FC_HTTP)
{
conn->fc_pub.hs = lsquic_headers_stream_new(
!!(conn->fc_flags & FC_SERVER), conn->fc_pub.mm, conn->fc_settings,
headers_callbacks_ptr, conn);
if (!conn->fc_pub.hs)
goto cleanup_on_error;
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if = lsquic_headers_stream_if;
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if_ctx = conn->fc_pub.hs;
headers_stream = new_stream(conn, LSQUIC_STREAM_HEADERS,
SCF_CALL_ON_NEW);
if (!headers_stream)
goto cleanup_on_error;
}
else
{
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if = stream_if;
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if_ctx = stream_if_ctx;
}
if (conn->fc_settings->es_support_push)
conn->fc_flags |= FC_SUPPORT_PUSH;
conn->fc_conn.cn_if = full_conn_iface_ptr;
return conn;
cleanup_on_error:
saved_errno = errno;
if (conn->fc_pub.all_streams)
lsquic_hash_destroy(conn->fc_pub.all_streams);
lsquic_rechist_cleanup(&conn->fc_rechist);
if (conn->fc_flags & FC_HTTP)
{
if (conn->fc_pub.hs)
lsquic_headers_stream_destroy(conn->fc_pub.hs);
if (headers_stream)
lsquic_stream_destroy(headers_stream);
}
memset(conn, 0, sizeof(*conn));
free(conn);
errno = saved_errno;
return NULL;
}
struct lsquic_conn *
full_conn_client_new (struct lsquic_engine_public *enpub,
const struct lsquic_stream_if *stream_if,
void *stream_if_ctx, unsigned flags,
const char *hostname, unsigned short max_packet_size)
{
struct full_conn *conn;
enum lsquic_version version;
lsquic_cid_t cid;
const struct enc_session_funcs *esf;
version = highest_bit_set(enpub->enp_settings.es_versions);
esf = select_esf_by_ver(version);
cid = esf->esf_generate_cid();
conn = new_conn_common(cid, enpub, stream_if, stream_if_ctx, flags,
max_packet_size);
if (!conn)
return NULL;
conn->fc_conn.cn_esf = esf;
conn->fc_conn.cn_enc_session =
conn->fc_conn.cn_esf->esf_create_client(hostname, cid, conn->fc_enpub);
if (!conn->fc_conn.cn_enc_session)
{
LSQ_WARN("could not create enc session: %s", strerror(errno));
conn->fc_conn.cn_if->ci_destroy(&conn->fc_conn);
return NULL;
}
if (conn->fc_flags & FC_HTTP)
conn->fc_last_stream_id = LSQUIC_STREAM_HEADERS; /* Client goes 5, 7, 9.... */
else
conn->fc_last_stream_id = LSQUIC_STREAM_HANDSHAKE;
conn->fc_hsk_ctx.client.lconn = &conn->fc_conn;
conn->fc_hsk_ctx.client.mm = &enpub->enp_mm;
conn->fc_hsk_ctx.client.ver_neg = &conn->fc_ver_neg;
conn->fc_stream_ifs[STREAM_IF_HSK]
.stream_if = &lsquic_client_hsk_stream_if;
conn->fc_stream_ifs[STREAM_IF_HSK].stream_if_ctx = &conn->fc_hsk_ctx.client;
init_ver_neg(conn, conn->fc_settings->es_versions);
conn->fc_conn.cn_pf = select_pf_by_ver(conn->fc_ver_neg.vn_ver);
if (conn->fc_settings->es_handshake_to)
lsquic_alarmset_set(&conn->fc_alset, AL_HANDSHAKE,
lsquic_time_now() + conn->fc_settings->es_handshake_to);
if (!new_stream(conn, LSQUIC_STREAM_HANDSHAKE, SCF_CALL_ON_NEW))
{
LSQ_WARN("could not create handshake stream: %s", strerror(errno));
conn->fc_conn.cn_if->ci_destroy(&conn->fc_conn);
return NULL;
}
conn->fc_flags |= FC_CREATED_OK;
LSQ_INFO("Created new client connection");
EV_LOG_CONN_EVENT(cid, "created full connection");
return &conn->fc_conn;
}
void
@ -829,7 +995,7 @@ lsquic_conn_get_engine (lsquic_conn_t *lconn)
}
static ssize_t
static ptrdiff_t
count_zero_bytes (const unsigned char *p, size_t len)
{
const unsigned char *const end = p + len;
@ -844,11 +1010,11 @@ process_padding_frame (struct full_conn *conn, lsquic_packet_in_t *packet_in,
const unsigned char *p, size_t len)
{
if (conn->fc_conn.cn_version >= LSQVER_038)
return (unsigned)count_zero_bytes(p, len);
return (unsigned) count_zero_bytes(p, len);
if (lsquic_is_zero(p, len))
{
EV_LOG_PADDING_FRAME_IN(LSQUIC_LOG_CONN_ID, len);
return (unsigned )len;
return (unsigned) len;
}
else
return 0;
@ -1133,11 +1299,19 @@ static int
process_saved_ack (struct full_conn *conn, int restore_parsed_ack)
{
struct ack_info *const acki = conn->fc_pub.mm->acki;
struct lsquic_packno_range range = { 0 };
unsigned n_ranges = 0, n_timestamps = 0;
lsquic_time_t lack_delta = 0;
struct lsquic_packno_range range;
unsigned n_ranges, n_timestamps;
lsquic_time_t lack_delta;
int retval;
#ifdef WIN32
/* Useless initialization to mollify MSVC: */
memset(&range, 0, sizeof(range));
n_ranges = 0;
n_timestamps = 0;
lack_delta = 0;
#endif
if (restore_parsed_ack)
{
n_ranges = acki->n_ranges;
@ -3179,7 +3353,7 @@ static const struct headers_stream_callbacks headers_callbacks =
.hsc_on_enable_push = headers_stream_on_enable_push,
};
static const struct headers_stream_callbacks *headers_callbacks_ptr = &headers_callbacks;
static const struct conn_iface full_conn_iface = {
.ci_destroy = full_conn_ci_destroy,
@ -3192,167 +3366,5 @@ static const struct conn_iface full_conn_iface = {
.ci_tick = full_conn_ci_tick,
.ci_user_wants_read = full_conn_ci_user_wants_read,
};
static struct full_conn *
new_conn_common (lsquic_cid_t cid, struct lsquic_engine_public *enpub,
const struct lsquic_stream_if *stream_if,
void *stream_if_ctx, unsigned flags,
unsigned short max_packet_size)
{
struct full_conn *conn;
lsquic_stream_t *headers_stream;
int saved_errno;
assert(0 == (flags & ~(FC_SERVER|FC_HTTP)));
conn = calloc(1, sizeof(*conn));
if (!conn)
return NULL;
headers_stream = NULL;
conn->fc_conn.cn_cid = cid;
conn->fc_conn.cn_pack_size = max_packet_size;
conn->fc_flags = flags;
conn->fc_enpub = enpub;
conn->fc_pub.enpub = enpub;
conn->fc_pub.mm = &enpub->enp_mm;
conn->fc_pub.lconn = &conn->fc_conn;
conn->fc_pub.send_ctl = &conn->fc_send_ctl;
conn->fc_pub.packet_out_malo =
lsquic_malo_create(sizeof(struct lsquic_packet_out));
conn->fc_stream_ifs[STREAM_IF_STD].stream_if = stream_if;
conn->fc_stream_ifs[STREAM_IF_STD].stream_if_ctx = stream_if_ctx;
conn->fc_settings = &enpub->enp_settings;
/* Calculate maximum number of incoming streams using the same mechanism
* and parameters as found in Chrome:
*/
conn->fc_cfg.max_streams_in =
(unsigned) ((float) enpub->enp_settings.es_max_streams_in * 1.1f);
if (conn->fc_cfg.max_streams_in <
enpub->enp_settings.es_max_streams_in + 10)
conn->fc_cfg.max_streams_in =
enpub->enp_settings.es_max_streams_in + 10;
/* `max_streams_out' gets reset when handshake is complete and we
* learn of peer settings. 100 seems like a sane default value
* because it is what other implementations use. In server mode,
* we do not open any streams until the handshake is complete; in
* client mode, we are limited to 98 outgoing requests alongside
* handshake and headers streams.
*/
conn->fc_cfg.max_streams_out = 100;
TAILQ_INIT(&conn->fc_pub.sending_streams);
TAILQ_INIT(&conn->fc_pub.read_streams);
TAILQ_INIT(&conn->fc_pub.write_streams);
TAILQ_INIT(&conn->fc_pub.service_streams);
STAILQ_INIT(&conn->fc_stream_ids_to_reset);
lsquic_conn_cap_init(&conn->fc_pub.conn_cap, LSQUIC_MIN_FCW);
lsquic_alarmset_init(&conn->fc_alset, cid);
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_IDLE, idle_alarm_expired, conn);
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_ACK, ack_alarm_expired, conn);
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_PING, ping_alarm_expired, conn);
lsquic_alarmset_init_alarm(&conn->fc_alset, AL_HANDSHAKE, handshake_alarm_expired, conn);
lsquic_set32_init(&conn->fc_closed_stream_ids[0]);
lsquic_set32_init(&conn->fc_closed_stream_ids[1]);
lsquic_cfcw_init(&conn->fc_pub.cfcw, &conn->fc_pub, conn->fc_settings->es_cfcw);
lsquic_send_ctl_init(&conn->fc_send_ctl, &conn->fc_alset, conn->fc_enpub,
&conn->fc_ver_neg, &conn->fc_pub, conn->fc_conn.cn_pack_size);
conn->fc_pub.all_streams = lsquic_hash_create();
if (!conn->fc_pub.all_streams)
goto cleanup_on_error;
lsquic_rechist_init(&conn->fc_rechist, cid);
if (conn->fc_flags & FC_HTTP)
{
conn->fc_pub.hs = lsquic_headers_stream_new(
!!(conn->fc_flags & FC_SERVER), conn->fc_pub.mm, conn->fc_settings,
&headers_callbacks, conn);
if (!conn->fc_pub.hs)
goto cleanup_on_error;
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if = lsquic_headers_stream_if;
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if_ctx = conn->fc_pub.hs;
headers_stream = new_stream(conn, LSQUIC_STREAM_HEADERS,
SCF_CALL_ON_NEW);
if (!headers_stream)
goto cleanup_on_error;
}
else
{
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if = stream_if;
conn->fc_stream_ifs[STREAM_IF_HDR].stream_if_ctx = stream_if_ctx;
}
if (conn->fc_settings->es_support_push)
conn->fc_flags |= FC_SUPPORT_PUSH;
conn->fc_conn.cn_if = &full_conn_iface;
return conn;
cleanup_on_error:
saved_errno = errno;
if (conn->fc_pub.all_streams)
lsquic_hash_destroy(conn->fc_pub.all_streams);
lsquic_rechist_cleanup(&conn->fc_rechist);
if (conn->fc_flags & FC_HTTP)
{
if (conn->fc_pub.hs)
lsquic_headers_stream_destroy(conn->fc_pub.hs);
if (headers_stream)
lsquic_stream_destroy(headers_stream);
}
memset(conn, 0, sizeof(*conn));
free(conn);
errno = saved_errno;
return NULL;
}
struct lsquic_conn *
full_conn_client_new (struct lsquic_engine_public *enpub,
const struct lsquic_stream_if *stream_if,
void *stream_if_ctx, unsigned flags,
const char *hostname, unsigned short max_packet_size)
{
struct full_conn *conn;
enum lsquic_version version;
lsquic_cid_t cid;
const struct enc_session_funcs *esf;
version = highest_bit_set(enpub->enp_settings.es_versions);
esf = select_esf_by_ver(version);
cid = esf->esf_generate_cid();
conn = new_conn_common(cid, enpub, stream_if, stream_if_ctx, flags,
max_packet_size);
if (!conn)
return NULL;
conn->fc_conn.cn_esf = esf;
conn->fc_conn.cn_enc_session =
conn->fc_conn.cn_esf->esf_create_client(hostname, cid, conn->fc_enpub);
if (!conn->fc_conn.cn_enc_session)
{
LSQ_WARN("could not create enc session: %s", strerror(errno));
conn->fc_conn.cn_if->ci_destroy(&conn->fc_conn);
return NULL;
}
if (conn->fc_flags & FC_HTTP)
conn->fc_last_stream_id = LSQUIC_STREAM_HEADERS; /* Client goes 5, 7, 9.... */
else
conn->fc_last_stream_id = LSQUIC_STREAM_HANDSHAKE;
conn->fc_hsk_ctx.client.lconn = &conn->fc_conn;
conn->fc_hsk_ctx.client.mm = &enpub->enp_mm;
conn->fc_hsk_ctx.client.ver_neg = &conn->fc_ver_neg;
conn->fc_stream_ifs[STREAM_IF_HSK]
.stream_if = &lsquic_client_hsk_stream_if;
conn->fc_stream_ifs[STREAM_IF_HSK].stream_if_ctx = &conn->fc_hsk_ctx.client;
init_ver_neg(conn, conn->fc_settings->es_versions);
conn->fc_conn.cn_pf = select_pf_by_ver(conn->fc_ver_neg.vn_ver);
if (conn->fc_settings->es_handshake_to)
lsquic_alarmset_set(&conn->fc_alset, AL_HANDSHAKE,
lsquic_time_now() + conn->fc_settings->es_handshake_to);
if (!new_stream(conn, LSQUIC_STREAM_HANDSHAKE, SCF_CALL_ON_NEW))
{
LSQ_WARN("could not create handshake stream: %s", strerror(errno));
conn->fc_conn.cn_if->ci_destroy(&conn->fc_conn);
return NULL;
}
conn->fc_flags |= FC_CREATED_OK;
LSQ_INFO("Created new client connection");
EV_LOG_CONN_EVENT(cid, "created full connection");
return &conn->fc_conn;
}
static const struct conn_iface *full_conn_iface_ptr = &full_conn_iface;

View file

@ -935,7 +935,7 @@ lsquic_enc_session_gen_chlo (lsquic_enc_session_t *enc_session,
unsigned char pub_key[32];
size_t ua_len;
uint32_t opts[1]; /* Only NSTP is supported for now */
unsigned n_opts, msg_len, n_tags, pad_size = 0;
unsigned n_opts, msg_len, n_tags, pad_size;
struct message_writer mw;
/* Before we do anything else, sanity check: */
@ -1014,6 +1014,10 @@ lsquic_enc_session_gen_chlo (lsquic_enc_session_t *enc_session,
pad_size = 0;
MSG_LEN_ADD(msg_len, pad_size); ++n_tags; /* PAD */
}
#ifdef WIN32
else
pad_size = 0;
#endif
/* Check that we have enough room in the output buffer: */
if (MSG_LEN_VAL(msg_len) > *len)

View file

@ -9,7 +9,9 @@
#include <stdlib.h>
#include <string.h>
#include <sys/queue.h>
#ifdef MSVC
#include <vc_compat.h>
#endif
#include "lsquic_types.h"
#include "lsquic_frame_common.h"
@ -29,6 +31,7 @@
#define LSQUIC_LOG_CONN_ID lsquic_conn_id(lsquic_stream_conn(hs->hs_stream))
#include "lsquic_logger.h"
static const struct frame_reader_callbacks *frame_callbacks_ptr;
struct headers_stream
{
@ -48,7 +51,6 @@ struct headers_stream
HS_HENC_INITED = (1 << 1),
} hs_flags;
};
static lsquic_stream_ctx_t * headers_on_new_stream(void *stream_if_ctx, lsquic_stream_t *stream);
int
@ -71,6 +73,42 @@ lsquic_headers_stream_send_settings (struct headers_stream *hs,
}
static lsquic_stream_ctx_t *
headers_on_new_stream (void *stream_if_ctx, lsquic_stream_t *stream)
{
struct headers_stream *hs = stream_if_ctx;
lsquic_hdec_init(&hs->hs_hdec);
if (0 != lsquic_henc_init(&hs->hs_henc))
{
LSQ_WARN("could not initialize HPACK encoder: %s", strerror(errno));
return NULL;
}
hs->hs_flags |= HS_HENC_INITED;
hs->hs_stream = stream;
LSQ_DEBUG("stream created");
hs->hs_fr = lsquic_frame_reader_new((hs->hs_flags & HS_IS_SERVER) ? FRF_SERVER : 0,
MAX_HEADERS_SIZE, hs->hs_mm,
stream, lsquic_stream_read, &hs->hs_hdec,
frame_callbacks_ptr, hs);
if (!hs->hs_fr)
{
LSQ_WARN("could not create frame reader: %s", strerror(errno));
hs->hs_callbacks->hsc_on_conn_error(hs->hs_cb_ctx);
return NULL;
}
hs->hs_fw = lsquic_frame_writer_new(hs->hs_mm, stream, 0, &hs->hs_henc,
lsquic_stream_write,
(hs->hs_flags & HS_IS_SERVER));
if (!hs->hs_fw)
{
LSQ_WARN("could not create frame writer: %s", strerror(errno));
hs->hs_callbacks->hsc_on_conn_error(hs->hs_cb_ctx);
return NULL;
}
lsquic_stream_wantread(stream, 1);
return (lsquic_stream_ctx_t *) hs;
}
static void
headers_on_read (lsquic_stream_t *stream, struct lsquic_stream_ctx *ctx)
@ -379,39 +417,6 @@ static const struct frame_reader_callbacks frame_callbacks = {
.frc_on_settings = headers_on_settings,
.frc_on_priority = headers_on_priority,
};
static lsquic_stream_ctx_t *
headers_on_new_stream (void *stream_if_ctx, lsquic_stream_t *stream)
{
struct headers_stream *hs = stream_if_ctx;
lsquic_hdec_init(&hs->hs_hdec);
if (0 != lsquic_henc_init(&hs->hs_henc))
{
LSQ_WARN("could not initialize HPACK encoder: %s", strerror(errno));
return NULL;
}
hs->hs_flags |= HS_HENC_INITED;
hs->hs_stream = stream;
LSQ_DEBUG("stream created");
hs->hs_fr = lsquic_frame_reader_new((hs->hs_flags & HS_IS_SERVER) ? FRF_SERVER : 0,
MAX_HEADERS_SIZE, hs->hs_mm,
stream, lsquic_stream_read, &hs->hs_hdec,
&frame_callbacks, hs);
if (!hs->hs_fr)
{
LSQ_WARN("could not create frame reader: %s", strerror(errno));
hs->hs_callbacks->hsc_on_conn_error(hs->hs_cb_ctx);
return NULL;
}
hs->hs_fw = lsquic_frame_writer_new(hs->hs_mm, stream, 0, &hs->hs_henc,
lsquic_stream_write,
(hs->hs_flags & HS_IS_SERVER));
if (!hs->hs_fw)
{
LSQ_WARN("could not create frame writer: %s", strerror(errno));
hs->hs_callbacks->hsc_on_conn_error(hs->hs_cb_ctx);
return NULL;
}
lsquic_stream_wantread(stream, 1);
return (lsquic_stream_ctx_t *) hs;
}
static const struct frame_reader_callbacks *frame_callbacks_ptr = &frame_callbacks;

View file

@ -121,10 +121,56 @@ lsquic_printf (const char *fmt, ...)
}
#ifdef WIN32
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
static int
gettimeofday (struct timeval *tv, struct timezone *tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag;
if (NULL != tv)
{
GetSystemTimeAsFileTime(&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
/*converting file time to unix epoch */
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tmpres /= 10; /*convert into microseconds */
tv->tv_sec = (long) (tmpres / 1000000UL);
tv->tv_usec = (long) (tmpres % 1000000UL);
}
if (NULL != tz)
{
if (!tzflag)
{
_tzset();
tzflag++;
}
tz->tz_minuteswest = _timezone / 60;
tz->tz_dsttime = _daylight;
}
return 0;
}
#endif
static void
print_timestamp (void)
{
#ifndef WIN32
struct tm tm;
struct timeval tv;
gettimeofday(&tv, NULL);
@ -146,27 +192,6 @@ print_timestamp (void)
else if (g_llts == LLTS_CHROMELIKE)
lsquic_printf("%02d%02d/%02d%02d%02d.%06d ", tm.tm_mon + 1,
tm.tm_mday,tm.tm_hour, tm.tm_min, tm.tm_sec, (int) tv.tv_usec);
#else
SYSTEMTIME tm = { 0 };
GetSystemTime(&tm);
if (g_llts == LLTS_YYYYMMDD_HHMMSSUS)
lsquic_printf("%04d-%02d-%02d %02d:%02d:%02d.%06d ",
tm.wYear + 1900, tm.wMonth + 1, tm.wDay,
tm.wHour, tm.wMinute, tm.wSecond, tm.wMilliseconds*1000 );
else if (g_llts == LLTS_YYYYMMDD_HHMMSSMS)
lsquic_printf("%04d-%02d-%02d %02d:%02d:%02d.%03d ",
tm.wYear + 1900, tm.wMonth + 1, tm.wDay,
tm.wHour, tm.wMinute, tm.wSecond, tm.wMilliseconds*1000 );
else if (g_llts == LLTS_HHMMSSMS)
lsquic_printf("%02d:%02d:%02d.%03d ", tm.wHour, tm.wMinute,
tm.wSecond, tm.wMilliseconds );
else if (g_llts == LLTS_HHMMSSUS)
lsquic_printf("%02d:%02d:%02d.%03d ", tm.wHour, tm.wMinute,
tm.wSecond, tm.wMilliseconds*1000 );
else if (g_llts == LLTS_CHROMELIKE)
lsquic_printf("%02d%02d/%02d%02d%02d.%06d ", tm.wMonth + 1,
tm.wDay,tm.wHour, tm.wMinute, tm.wSecond, (int) tm.wMilliseconds*1000);
#endif
}

View file

@ -65,23 +65,23 @@ static const char * const frame_type_2_str[N_QUIC_FRAMES] = {
};
#define SLEN(x) (sizeof(#x) - sizeof("QUIC_FRAME_"))
#define QUIC_FRAME_SLEN(x) (sizeof(#x) - sizeof("QUIC_FRAME_"))
/* We don't need to include INVALID frame in this list because it is
* never a part of any frame list bitmask (e.g. po_frame_types).
*/
#define lsquic_frame_types_str_sz \
SLEN(QUIC_FRAME_STREAM) + 1 + \
SLEN(QUIC_FRAME_ACK) + 1 + \
SLEN(QUIC_FRAME_PADDING) + 1 + \
SLEN(QUIC_FRAME_RST_STREAM) + 1 + \
SLEN(QUIC_FRAME_CONNECTION_CLOSE) + 1 + \
SLEN(QUIC_FRAME_GOAWAY) + 1 + \
SLEN(QUIC_FRAME_WINDOW_UPDATE) + 1 + \
SLEN(QUIC_FRAME_BLOCKED) + 1 + \
SLEN(QUIC_FRAME_STOP_WAITING) + 1 + \
SLEN(QUIC_FRAME_PING) + 1
QUIC_FRAME_SLEN(QUIC_FRAME_STREAM) + 1 + \
QUIC_FRAME_SLEN(QUIC_FRAME_ACK) + 1 + \
QUIC_FRAME_SLEN(QUIC_FRAME_PADDING) + 1 + \
QUIC_FRAME_SLEN(QUIC_FRAME_RST_STREAM) + 1 + \
QUIC_FRAME_SLEN(QUIC_FRAME_CONNECTION_CLOSE) + 1 + \
QUIC_FRAME_SLEN(QUIC_FRAME_GOAWAY) + 1 + \
QUIC_FRAME_SLEN(QUIC_FRAME_WINDOW_UPDATE) + 1 + \
QUIC_FRAME_SLEN(QUIC_FRAME_BLOCKED) + 1 + \
QUIC_FRAME_SLEN(QUIC_FRAME_STOP_WAITING) + 1 + \
QUIC_FRAME_SLEN(QUIC_FRAME_PING) + 1

View file

@ -6,7 +6,6 @@
#ifndef LSQUIC_PACKET_IN_H
#define LSQUIC_PACKET_IN_H 1
struct lsquic_packet_in;
struct data_frame

View file

@ -615,7 +615,7 @@ lsquic_packet_out_split_in_two (struct lsquic_mm *mm,
struct stream_rec **new_srecs, **srecs = local_arr;
struct stream_rec *srec;
unsigned n_srecs_alloced = sizeof(local_arr) / sizeof(local_arr[0]);
unsigned n_srecs, max_idx = 0, n, nbytes;
unsigned n_srecs, max_idx, n, nbytes;
#ifndef NDEBUG
unsigned short frame_sum = 0;
#endif
@ -627,6 +627,9 @@ lsquic_packet_out_split_in_two (struct lsquic_mm *mm,
assert(packet_out->po_frame_types == (1 << QUIC_FRAME_STREAM));
n_srecs = 0;
#ifdef WIN32
max_idx = 0;
#endif
for (srec = posi_first(&posi, packet_out); srec; srec = posi_next(&posi))
{
/* We only expect references to STREAM frames (buffered packets): */

View file

@ -364,6 +364,7 @@ gquic_ietf_gen_ack_frame (unsigned char *outbuf, size_t outbuf_sz,
void *rechist, lsquic_time_t now, int *has_missing,
lsquic_packno_t *largest_received)
{
lsquic_time_t time_diff;
lsquic_packno_t tmp_packno;
const struct lsquic_packno_range *const first = rechist_first(rechist);
if (!first)
@ -447,13 +448,11 @@ gquic_ietf_gen_ack_frame (unsigned char *outbuf, size_t outbuf_sz,
p += largest_acked_len;
CHECKOUT(2);
{
lsquic_time_t diff = now - rechist_largest_recv(rechist);
gquic_be_write_float_time16(diff, p);
LSQ_DEBUG("%s: diff: %"PRIu64"; encoded: 0x%04X", __func__, diff,
*(uint16_t*)p);
p += 2;
}
time_diff = now - rechist_largest_recv(rechist);
gquic_be_write_float_time16(time_diff, p);
LSQ_DEBUG("%s: diff: %"PRIu64"; encoded: 0x%04X", __func__, time_diff,
*(uint16_t*)p);
p += 2;
*has_missing = n_ranges > 1;
if (n_ranges > 1)

View file

@ -796,6 +796,7 @@ gquic_be_gen_ack_frame (unsigned char *outbuf, size_t outbuf_sz,
void *rechist, lsquic_time_t now, int *has_missing,
lsquic_packno_t *largest_received)
{
lsquic_time_t time_diff;
lsquic_packno_t tmp_packno;
const struct lsquic_packno_range *const first = rechist_first(rechist);
if (!first)
@ -865,13 +866,11 @@ gquic_be_gen_ack_frame (unsigned char *outbuf, size_t outbuf_sz,
p += largest_acked_len;
CHECKOUT(2);
{
lsquic_time_t diff = now - rechist_largest_recv(rechist);
gquic_be_write_float_time16(diff, p);
LSQ_DEBUG("%s: diff: %"PRIu64"; encoded: 0x%04X", __func__, diff,
*(uint16_t*)p);
p += 2;
}
time_diff = now - rechist_largest_recv(rechist);
gquic_be_write_float_time16(time_diff, p);
LSQ_DEBUG("%s: diff: %"PRIu64"; encoded: 0x%04X", __func__, time_diff,
*(uint16_t*)p);
p += 2;
if (n_ranges > 1)
{

View file

@ -690,6 +690,7 @@ gquic_le_gen_ack_frame (unsigned char *outbuf, size_t outbuf_sz,
void *rechist, lsquic_time_t now, int *has_missing,
lsquic_packno_t *largest_received)
{
lsquic_time_t time_diff;
const struct lsquic_packno_range *const first = rechist_first(rechist);
if (!first)
{
@ -753,13 +754,11 @@ gquic_le_gen_ack_frame (unsigned char *outbuf, size_t outbuf_sz,
p += largest_acked_len;
CHECKOUT(2);
{
lsquic_time_t diff = now - rechist_largest_recv(rechist);
gquic_le_write_float_time16(diff, p);
LSQ_DEBUG("%s: diff: %"PRIu64"; encoded: 0x%04X", __func__, diff,
*(uint16_t*)p);
p += 2;
}
time_diff = now - rechist_largest_recv(rechist);
gquic_le_write_float_time16(time_diff, p);
LSQ_DEBUG("%s: diff: %"PRIu64"; encoded: 0x%04X", __func__, time_diff,
*(uint16_t*)p);
p += 2;
if (n_ranges > 1)
{

View file

@ -8,7 +8,9 @@
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#ifdef MSVC
#include <vc_compat.h>
#endif
#include "lsquic_int_types.h"
#include "lsquic_types.h"

View file

@ -299,7 +299,7 @@ static void
set_retx_alarm (lsquic_send_ctl_t *ctl)
{
enum retx_mode rm;
lsquic_time_t delay = 0, now;
lsquic_time_t delay, now;
assert(!TAILQ_EMPTY(&ctl->sc_unacked_packets));
@ -339,6 +339,10 @@ set_retx_alarm (lsquic_send_ctl_t *ctl)
*/
delay = calculate_packet_rto(ctl);
break;
#ifdef WIN32
default:
delay = 0;
#endif
}
if (delay > MAX_RTO_DELAY)
@ -926,7 +930,7 @@ static void
send_ctl_expire (lsquic_send_ctl_t *ctl, enum expire_filter filter)
{
lsquic_packet_out_t *packet_out, *next;
int n_resubmitted =0;
int n_resubmitted;
static const char *const filter_type2str[] = {
[EXFI_ALL] = "all",
[EXFI_HSK] = "handshake",
@ -957,6 +961,10 @@ send_ctl_expire (lsquic_send_ctl_t *ctl, enum expire_filter filter)
else
n_resubmitted = 0;
break;
#ifdef WIN32
default:
n_resubmitted = 0;
#endif
}
LSQ_DEBUG("consider %s packets lost: %d resubmitted",
@ -1301,11 +1309,14 @@ lsquic_send_ctl_set_tcid0 (lsquic_send_ctl_t *ctl, int tcid0)
void
lsquic_send_ctl_elide_stream_frames (lsquic_send_ctl_t *ctl, uint32_t stream_id)
{
struct lsquic_packet_out *packet_out, *next = NULL;
struct lsquic_packet_out *packet_out, *next;
struct lsquic_packet_out *pre_dropped;
unsigned n, adj;
pre_dropped = NULL;
#ifdef WIN32
next = NULL;
#endif
for (packet_out = TAILQ_FIRST(&ctl->sc_scheduled_packets); packet_out;
packet_out = next)
{