Fix Windows support

This commit is contained in:
Dmitri Tikhonov 2020-06-03 00:13:30 -04:00
parent 41d574f34c
commit fb3e20e0bc
72 changed files with 912 additions and 475 deletions

View file

@ -79,7 +79,9 @@ SET(lsquic_STAT_SRCS
lsquic_version.c
)
IF(NOT MSVC)
set_source_files_properties(ls-qpack/lsqpack.c PROPERTIES COMPILE_FLAGS -Wno-uninitialized)
ENDIF()
include_directories(ls-qpack)
@ -95,8 +97,8 @@ ENDIF()
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/lsquic_versions_to_string.c
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/gen-verstrs.pl
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/../../include/lsquic.h ${CMAKE_CURRENT_SOURCE_DIR}/lsquic_versions_to_string.c
COMMAND ${PERL}
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/gen-verstrs.pl ${CMAKE_CURRENT_SOURCE_DIR}/../../include/lsquic.h ${CMAKE_CURRENT_SOURCE_DIR}/lsquic_versions_to_string.c
DEPENDS ./gen-verstrs.pl ${CMAKE_CURRENT_SOURCE_DIR}/../../include/lsquic.h
)
SET(lsquic_STAT_SRCS ${lsquic_STAT_SRCS} lsquic_versions_to_string.c)

View file

@ -180,7 +180,7 @@ init_bbr (struct lsquic_bbr *bbr)
bbr->bbr_min_cwnd = kDefaultMinimumCongestionWindow;
bbr->bbr_high_gain = kDefaultHighGain;
bbr->bbr_high_cwnd_gain = kDefaultHighGain;
bbr->bbr_drain_gain = 1.0 / kDefaultHighGain;
bbr->bbr_drain_gain = 1.0f / kDefaultHighGain;
bbr->bbr_pacing_rate = BW_ZERO();
bbr->bbr_pacing_gain = 1.0;
bbr->bbr_cwnd_gain = 1.0;
@ -298,7 +298,7 @@ is_pipe_sufficiently_full (struct lsquic_bbr *bbr, uint64_t bytes_in_flight)
else
// If bytes_in_flight are above the target congestion window, it should
// be possible to observe the same or more bandwidth if it's available.
return bytes_in_flight >= get_target_cwnd(bbr, 1.1);
return bytes_in_flight >= get_target_cwnd(bbr, 1.1f);
}

View file

@ -79,11 +79,11 @@ bw_sampler_abort_conn (struct bw_sampler *sampler)
}
#define BW_WARN_ONCE(msg...) do { \
#define BW_WARN_ONCE(...) do { \
if (!(sampler->bws_flags & BWS_WARNED)) \
{ \
sampler->bws_flags |= BWS_WARNED; \
LSQ_WARN(msg); \
LSQ_WARN(__VA_ARGS__); \
} \
} while (0)

View file

@ -1545,6 +1545,8 @@ get_peer_transport_params (struct enc_sess_iquic *enc_sess)
}
else if ((enc_sess->esi_flags & (ESI_RETRY|ESI_SERVER)) == ESI_RETRY)
must_have = 1 << TPI_ORIGINAL_DEST_CID;
else
must_have = 0;
enum transport_param_id tpi;
for (tpi = FIRST_TP_CID; tpi <= LAST_TP_CID; ++tpi)

View file

@ -25,6 +25,15 @@
#ifndef NDEBUG
#include <sys/types.h>
#endif
#if defined(WIN32) || defined(NDEBUG)
#define CAN_LOSE_PACKETS 0
#else
#define CAN_LOSE_PACKETS 1
#endif
#if CAN_LOSE_PACKETS
#include <regex.h> /* For code that loses packets */
#endif
@ -208,7 +217,11 @@ struct lsquic_engine
= (1 << 9), /* Connections are hashed by address */
#ifndef NDEBUG
ENG_COALESCE = (1 << 24), /* Packet coalescing is enabled */
#endif
#if CAN_LOSE_PACKETS
ENG_LOSE_PACKETS= (1 << 25), /* Lose *some* outgoing packets */
#endif
#ifndef NDEBUG
ENG_DTOR = (1 << 26), /* Engine destructor */
#endif
} flags;
@ -230,7 +243,7 @@ struct lsquic_engine
* priority lower than that of existing connections.
*/
lsquic_time_t last_sent;
#ifndef NDEBUG
#if CAN_LOSE_PACKETS
regex_t lose_packets_re;
const char *lose_packets_str;
#endif
@ -639,6 +652,7 @@ lsquic_engine_new (unsigned flags,
{
const char *env;
env = getenv("LSQUIC_LOSE_PACKETS_RE");
#if CAN_LOSE_PACKETS
if (env)
{
if (0 != regcomp(&engine->lose_packets_re, env,
@ -652,6 +666,7 @@ lsquic_engine_new (unsigned flags,
LSQ_WARN("will lose packets that match the following regex: %s",
env);
}
#endif
env = getenv("LSQUIC_COALESCE");
if (env)
{
@ -1439,7 +1454,7 @@ lsquic_engine_destroy (lsquic_engine_t *engine)
lsquic_stock_shared_hash_destroy(engine->pub.enp_shi_ctx);
lsquic_mm_cleanup(&engine->pub.enp_mm);
free(engine->conns_tickable.mh_elems);
#ifndef NDEBUG
#if CAN_LOSE_PACKETS
if (engine->flags & ENG_LOSE_PACKETS)
regfree(&engine->lose_packets_re);
#endif
@ -2037,7 +2052,7 @@ coi_reheap (struct conns_out_iter *iter, lsquic_engine_t *engine)
}
#ifndef NDEBUG
#if CAN_LOSE_PACKETS
static void
lose_matching_packets (const lsquic_engine_t *engine, struct out_batch *batch,
unsigned n)
@ -2136,7 +2151,7 @@ send_batch (lsquic_engine_t *engine, const struct send_batch_ctx *sb_ctx,
CONST_BATCH struct out_batch *const batch = sb_ctx->batch;
struct lsquic_packet_out *CONST_BATCH *packet_out, *CONST_BATCH *end;
#ifndef NDEBUG
#if CAN_LOSE_PACKETS
if (engine->flags & ENG_LOSE_PACKETS)
lose_matching_packets(engine, batch, n_to_send);
#endif
@ -2699,12 +2714,11 @@ lsquic_engine_packet_in (lsquic_engine_t *engine,
parse_packet_in_begin = lsquic_Q050_parse_packet_in_begin;
else
{
assert(conn->cn_version == LSQVER_046
#if LSQUIC_USE_Q098
|| conn->cn_version == LSQVER_098
assert(conn->cn_version == LSQVER_046 || conn->cn_version == LSQVER_098);
#else
assert(conn->cn_version == LSQVER_046);
#endif
);
parse_packet_in_begin = lsquic_Q046_parse_packet_in_begin;
}
}
@ -2714,6 +2728,11 @@ lsquic_engine_packet_in (lsquic_engine_t *engine,
engine->curr_conn = NULL;
n_zeroes = 0;
is_ietf = 0;
#ifdef _MSC_VER
s = 0;
cid.len = 0;
cid.idbuf[0] = 0;
#endif
do
{
packet_in = lsquic_mm_get_packet_in(&engine->pub.enp_mm);

View file

@ -528,15 +528,10 @@ lsquic_frame_writer_write_promise (struct lsquic_frame_writer *fw,
free(buf);
if (0 == s)
{
EV_LOG_GENERATED_HTTP_PUSH_PROMISE(LSQUIC_LOG_CONN_ID, stream_id,
htonl(promised_stream_id), headers);
hfc_terminate_frame(&hfc, HFHF_END_HEADERS);
return lsquic_frame_writer_flush(fw);
}
else
return -1;
EV_LOG_GENERATED_HTTP_PUSH_PROMISE(LSQUIC_LOG_CONN_ID, stream_id,
htonl(promised_stream_id), headers);
hfc_terminate_frame(&hfc, HFHF_END_HEADERS);
return lsquic_frame_writer_flush(fw);
}

View file

@ -7740,4 +7740,4 @@ static const struct lsquic_stream_if unicla_if =
static const struct lsquic_stream_if *unicla_if_ptr = &unicla_if;
typedef char dcid_elem_fits_in_128_bytes[(sizeof(struct dcid_elem) <= 128) - 1];
typedef char dcid_elem_fits_in_128_bytes[sizeof(struct dcid_elem) <= 128 ? 1 : - 1];

View file

@ -1,9 +1,6 @@
/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. */
#define _GNU_SOURCE /* for memmem */
#include <netinet/in.h>
#include <netdb.h>
#include <assert.h>
#include <errno.h>
#include <limits.h>
@ -11,6 +8,8 @@
#include <string.h>
#include <sys/queue.h>
#ifndef WIN32
#include <netinet/in.h>
#include <netdb.h>
#include <sys/socket.h>
#endif

View file

@ -126,12 +126,12 @@ lsquic_hcso_write_settings (struct hcso_writer *writer,
unsigned bits;
int was_empty;
#ifdef NDEBUG
const unsigned frame_size_len = 1;
# define frame_size_len 1
#else
/* Need to use two bytes for frame length, as randomization may require
* more than 63 bytes.
*/
const unsigned frame_size_len = 2;
# define frame_size_len 2
#endif
unsigned char buf[1 /* Frame type */ + /* Frame size */ frame_size_len
/* There are maximum three settings that need to be written out and

View file

@ -81,17 +81,8 @@ static lsquic_stream_ctx_t *
headers_on_new_stream (void *stream_if_ctx, lsquic_stream_t *stream)
{
struct headers_stream *hs = stream_if_ctx;
enum lshpack_dec_flags flags;
flags = 0;
if (hs->hs_enpub->enp_hsi_if->hsi_flags & LSQUIC_HSI_HTTP1X)
flags |= LSHPACK_DEC_HTTP1X;
if (hs->hs_enpub->enp_hsi_if->hsi_flags & LSQUIC_HSI_HASH_NAME)
flags |= LSHPACK_DEC_HASH_NAME;
if (hs->hs_enpub->enp_hsi_if->hsi_flags & LSQUIC_HSI_HASH_NAMEVAL)
flags |= LSHPACK_DEC_HASH_NAMEVAL;
lshpack_dec_init(&hs->hs_hdec, flags);
lshpack_dec_init(&hs->hs_hdec);
if (0 != lshpack_enc_init(&hs->hs_henc))
{
LSQ_WARN("could not initialize HPACK encoder: %s", strerror(errno));

View file

@ -17,7 +17,12 @@ lsquic_qhkdf_expand (const EVP_MD *md, const unsigned char *secret,
#ifndef NDEBUG
int s;
#endif
const size_t len = 2 + 1 + 6 + label_len + 1;
#ifndef WIN32
unsigned char info[ 2 + 1 + 6 + label_len + 1];
#else
unsigned char info[ 2 + 1 + 6 + UINT8_MAX + 1];
#endif
info[0] = out_len >> 8;
info[1] = out_len;
@ -35,6 +40,6 @@ lsquic_qhkdf_expand (const EVP_MD *md, const unsigned char *secret,
#else
(void)
#endif
HKDF_expand(out, out_len, md, secret, secret_len, info, sizeof(info));
HKDF_expand(out, out_len, md, secret, secret_len, info, len);
assert(s);
}

View file

@ -527,17 +527,13 @@ h1h_prepare_decode (void *hset, struct lsxpack_header *xhdr, size_t req_space)
if (0 == hwc->hwc_header_buf_nalloc
|| req_space > hwc->hwc_header_buf_nalloc)
{
if (req_space < 0x100)
nalloc = 0x100;
else
nalloc = req_space;
buf = malloc(nalloc);
buf = malloc(req_space);
if (!buf)
{
LSQ_DEBUG("cannot allocate %zd bytes", nalloc);
LSQ_DEBUG("cannot allocate %zd bytes", req_space);
return NULL;
}
hwc->hwc_header_buf_nalloc = nalloc;
hwc->hwc_header_buf_nalloc = req_space;
}
else
buf = hwc->hwc_xhdr.buf;

View file

@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/queue.h>
#include <time.h>
#include "lsquic.h"
#include "lsquic_int_types.h"
@ -95,7 +96,7 @@ process_deferred_packets (struct mini_conn *mc);
/* If this is not true, highest_bit_set() may be broken */
typedef char packno_set_is_unsigned_long[
(sizeof(unsigned long long) == sizeof(mconn_packno_set_t)) - 1];
sizeof(unsigned long long) == sizeof(mconn_packno_set_t) ? 1 : -1 ];
static unsigned
highest_bit_set (unsigned long long sz)
@ -2030,7 +2031,10 @@ mini_conn_ci_destroy (struct lsquic_conn *lconn)
(int) (sizeof(mc->mc_hist_buf) - hist_idx),
mc->mc_hist_buf + hist_idx, (int) hist_idx, mc->mc_hist_buf);
#else
LSQ_LOG(log_level, "destroyed. Diagnostics: conn flags: 0x%X, "
if (LSQ_LOG_ENABLED(log_level))
lsquic_logger_log2(log_level, LSQUIC_LOGGER_MODULE,
LSQUIC_LOG_CONN_ID,
"destroyed. Diagnostics: conn flags: 0x%X, "
"mc flags: 0x%X, "
#if LSQUIC_RECORD_INORD_HIST
"incoming-history (trunc: %d) %s, "
@ -2235,8 +2239,8 @@ static const struct conn_iface mini_conn_iface_standard_Q050 = {
typedef char largest_recv_holds_at_least_16_seconds[
((1 << (sizeof(((struct mini_conn *) 0)->mc_largest_recv) * 8)) / 1000000
>= 16) - 1];
>= 16) ? 1 : -1];
typedef char max_lifespan_smaller_than_largest_recv[
((1 << (sizeof(((struct mini_conn *) 0)->mc_largest_recv) * 8)) >
MAX_MINI_CONN_LIFESPAN_IN_USEC) - 1];
MAX_MINI_CONN_LIFESPAN_IN_USEC) ? 1 : -1];

View file

@ -6,6 +6,10 @@
#ifndef LSQUIC_PARSE_COMMON_H
#define LSQUIC_PARSE_COMMON_H 1
#ifdef WIN32
#include "vc_compat.h"
#endif
struct lsquic_packet_in;
struct packin_parse_state;

View file

@ -160,7 +160,7 @@ static const unsigned char simple_prst_payload[] = {
typedef char correct_simple_prst_size[(GQUIC_RESET_SZ ==
1 + GQUIC_CID_LEN + sizeof(simple_prst_payload)) - 1];
1 + GQUIC_CID_LEN + sizeof(simple_prst_payload)) ? 1 : -1 ];
ssize_t

View file

@ -353,6 +353,10 @@ ietf_v1_gen_stream_frame (unsigned char *buf, size_t buf_len,
unsigned slen, olen, dlen;
unsigned char *p = buf + 1;
#if _MSC_VER
obits = 0, dbits = 0;
#endif
assert(!!fin ^ !!size);
/* We do not check that stream_id, offset, and size are smaller

View file

@ -6,11 +6,14 @@
#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/queue.h>
#ifndef WIN32
#include <netinet/in.h>
#include <sys/socket.h>
#endif
#include <openssl/aead.h>
#include <openssl/rand.h>

View file

@ -10,6 +10,10 @@
#include <string.h>
#include <sys/queue.h>
#ifdef WIN32
#include <malloc.h>
#endif
#include "lsquic.h"
#include "lsquic_types.h"
#include "lsquic_int_types.h"
@ -333,13 +337,22 @@ qeh_write_headers (struct qpack_enc_hdl *qeh, lsquic_stream_id_t stream_id,
enum lsqpack_enc_status st;
int i, s, write_to_stream;
enum lsqpack_enc_flags enc_flags;
enum qwh_status retval;
#ifndef WIN32
unsigned char enc_buf[ qeh->qeh_encoder.qpe_cur_max_capacity * 2 ];
#else
unsigned char *enc_buf;
enc_buf = _malloca(qeh->qeh_encoder.qpe_cur_max_capacity * 2);
if (!enc_buf)
return QWH_ERR;
#endif
s = lsqpack_enc_start_header(&qeh->qeh_encoder, stream_id, 0);
if (s != 0)
{
LSQ_WARN("cannot start header");
return QWH_ERR;
retval = QWH_ERR;
goto end;
}
LSQ_DEBUG("begin encoding headers for stream %"PRIu64, stream_id);
@ -384,7 +397,8 @@ qeh_write_headers (struct qpack_enc_hdl *qeh, lsquic_stream_id_t stream_id,
{
LSQ_INFO("could not write to encoder stream: %s",
strerror(errno));
return QWH_ERR;
retval = QWH_ERR;
goto end;
}
write_to_stream = 0;
enc_p = enc_buf + (size_t) nw;
@ -395,18 +409,22 @@ qeh_write_headers (struct qpack_enc_hdl *qeh, lsquic_stream_id_t stream_id,
if (0 != lsquic_frab_list_write(&qeh->qeh_fral, enc_p, enc_sz))
{
LSQ_INFO("could not write to frab list");
return QWH_ERR;
retval = QWH_ERR;
goto end;
}
}
break;
case LQES_NOBUF_HEAD:
return QWH_ENOBUF;
retval = QWH_ENOBUF;
goto end;
default:
assert(0);
return QWH_ERR;
retval = QWH_ERR;
goto end;
case LQES_NOBUF_ENC:
LSQ_DEBUG("not enough room to write encoder stream data");
return QWH_ERR;
retval = QWH_ERR;
goto end;
}
}
@ -415,7 +433,8 @@ qeh_write_headers (struct qpack_enc_hdl *qeh, lsquic_stream_id_t stream_id,
if (nw <= 0)
{
LSQ_WARN("could not end header: %zd", nw);
return QWH_ERR;
retval = QWH_ERR;
goto end;
}
if ((size_t) nw < *prefix_sz)
@ -429,7 +448,8 @@ qeh_write_headers (struct qpack_enc_hdl *qeh, lsquic_stream_id_t stream_id,
LSQ_DEBUG("all %zd bytes of encoder stream written out; header block "
"is %zd bytes; estimated compression ratio %.3f", total_enc_sz,
*headers_sz, lsqpack_enc_ratio(&qeh->qeh_encoder));
return QWH_FULL;
retval = QWH_FULL;
goto end;
}
else
{
@ -439,8 +459,15 @@ qeh_write_headers (struct qpack_enc_hdl *qeh, lsquic_stream_id_t stream_id,
"buffered; header block is %zd bytes; estimated compression ratio "
"%.3f", total_enc_sz, lsquic_frab_list_size(&qeh->qeh_fral),
*headers_sz, lsqpack_enc_ratio(&qeh->qeh_encoder));
return QWH_PARTIAL;
retval = QWH_PARTIAL;
goto end;
}
end:
#ifdef WIN32
_freea(enc_buf);
#endif
return retval;
}

View file

@ -1542,6 +1542,9 @@ lsquic_send_ctl_do_sanity_check (const struct lsquic_send_ctl *ctl)
unsigned count, bytes;
enum packnum_space pns;
#if _MSC_VER
prev_packno = 0;
#endif
count = 0, bytes = 0;
for (pns = PNS_INIT; pns <= PNS_APP; ++pns)
{

View file

@ -12,10 +12,13 @@
#include <stdlib.h>
#include <string.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <netdb.h>
#include <time.h>
#ifndef WIN32
#include <netdb.h>
#include <sys/socket.h>
#endif
#include "lsquic_int_types.h"
#include "lsquic.h"

View file

@ -205,4 +205,4 @@ const struct lsquic_shared_hash_if stock_shi =
/* Need this to save one malloc using malo: */
typedef char hash_not_larger_than_hash_elem [
(sizeof(struct stock_shared_hash) <= sizeof(struct hash_elem)) - 1];
(sizeof(struct stock_shared_hash) <= sizeof(struct hash_elem)) ? 1 : -1];

View file

@ -26,6 +26,10 @@
#include <sys/queue.h>
#include <stddef.h>
#ifdef WIN32
#include <malloc.h>
#endif
#include "fiu-local.h"
#include "lsquic.h"
@ -3173,6 +3177,10 @@ update_buffered_hq_frames (struct lsquic_stream *stream, size_t len,
uint64_t cur_off, end;
size_t frame_sz;
unsigned extendable;
#if _MSC_VER
end = 0;
extendable = 0;
#endif
cur_off = stream->sm_payload + stream->sm_n_buffered;
STAILQ_FOREACH(shf, &stream->sm_hq_frames, shf_next)
@ -3437,7 +3445,15 @@ send_headers_ietf (struct lsquic_stream *stream,
ssize_t nw;
unsigned char *header_block;
enum lsqpack_enc_header_flags hflags;
unsigned char buf[max_push_size + max_prefix_size + MAX_HEADERS_SIZE];
int rv;
const size_t buf_sz = max_push_size + max_prefix_size + MAX_HEADERS_SIZE;
#ifndef WIN32
unsigned char buf[buf_sz];
#else
unsigned char *buf = _malloca(buf_sz);
if (!buf)
return -1;
#endif
stream->stream_flags &= ~STREAM_PUSHING;
stream->stream_flags |= STREAM_NOPUSH;
@ -3446,7 +3462,7 @@ send_headers_ietf (struct lsquic_stream *stream,
* back to a larger buffer if that fails.
*/
prefix_sz = max_prefix_size;
headers_sz = sizeof(buf) - max_prefix_size - max_push_size;
headers_sz = buf_sz - max_prefix_size - max_push_size;
qwh = lsquic_qeh_write_headers(stream->conn_pub->u.ietf.qeh, stream->id, 0,
headers, buf + max_push_size + max_prefix_size, &prefix_sz,
&headers_sz, &stream->sm_hb_compl, &hflags);
@ -3457,7 +3473,7 @@ send_headers_ietf (struct lsquic_stream *stream,
LSQ_INFO("not enough room for header block");
else
LSQ_WARN("internal error encoding and sending HTTP headers");
return -1;
goto err;
}
if (hflags & LSQECH_REF_NEW_ENTRIES)
@ -3471,7 +3487,7 @@ send_headers_ietf (struct lsquic_stream *stream,
if (!stream_activate_hq_frame(stream,
stream->sm_payload + stream->sm_n_buffered, HQFT_PUSH_PREAMBLE,
SHF_FIXED_SIZE|SHF_PHANTOM, push_sz))
return -1;
goto err;
buf[max_push_size + max_prefix_size - prefix_sz - push_sz] = HQUST_PUSH;
vint_write(buf + max_push_size + max_prefix_size - prefix_sz
- push_sz + 1,stream->sm_promise->pp_id, bits, 1 << bits);
@ -3485,7 +3501,7 @@ send_headers_ietf (struct lsquic_stream *stream,
if (!stream_activate_hq_frame(stream,
stream->sm_payload + stream->sm_n_buffered + push_sz,
HQFT_HEADERS, SHF_FIXED_SIZE, hblock_sz - push_sz))
return -1;
goto err;
if (qwh == QWH_FULL)
{
@ -3496,14 +3512,14 @@ send_headers_ietf (struct lsquic_stream *stream,
if (nw < 0)
{
LSQ_WARN("cannot write to stream: %s", strerror(errno));
return -1;
goto err;
}
if ((size_t) nw == hblock_sz)
{
stream->stream_flags |= STREAM_HEADERS_SENT;
stream_hblock_sent(stream);
LSQ_DEBUG("wrote all %zu bytes of header block", hblock_sz);
return 0;
goto end;
}
LSQ_DEBUG("wrote only %zd bytes of header block, stash", nw);
}
@ -3528,14 +3544,25 @@ send_headers_ietf (struct lsquic_stream *stream,
{
LSQ_WARN("cannot allocate %zd bytes to stash %s header block",
hblock_sz - (size_t) nw, qwh == QWH_FULL ? "full" : "partial");
return -1;
goto err;
}
memcpy(stream->sm_header_block, header_block + (size_t) nw,
hblock_sz - (size_t) nw);
stream->sm_hblock_sz = hblock_sz - (size_t) nw;
stream->sm_hblock_off = 0;
LSQ_DEBUG("stashed %u bytes of header block", stream->sm_hblock_sz);
return 0;
end:
rv = 0;
clean:
#ifdef WIN32
_freea(buf);
#endif
return rv;
err:
rv = -1;
goto clean;
}
@ -4560,7 +4587,7 @@ pp_reader_read (void *lsqr_ctx, void *buf, size_t count)
{
struct push_promise *const promise = lsqr_ctx;
unsigned char *dst = buf;
unsigned char *const end = buf + count;
unsigned char *const end = dst + count;
size_t len;
while (dst < end)

View file

@ -1,13 +1,16 @@
/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. */
#include <assert.h>
#include <netinet/in.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <time.h>
#ifndef WIN32
#include <netinet/in.h>
#include <sys/socket.h>
#endif
#include <openssl/aead.h>
#include <openssl/hkdf.h>
#include <openssl/rand.h>

View file

@ -11,8 +11,13 @@
#include <stdint.h>
#include <string.h>
#ifndef WIN32
#include <arpa/inet.h>
#include <sys/socket.h>
#else
#include "vc_compat.h"
#include "Ws2tcpip.h"
#endif
#include "lsquic_byteswap.h"
#include "lsquic_int_types.h"

View file

@ -141,10 +141,10 @@ struct transport_params
int
lsquic_tp_encode (const struct transport_params *, int is_server,
unsigned char *buf, size_t bufsz);
unsigned char *const buf, size_t bufsz);
int
lsquic_tp_decode (const unsigned char *buf, size_t bufsz,
lsquic_tp_decode (const unsigned char *const buf, size_t bufsz,
/* This argument specifies whose transport parameters we are parsing. If
* true, we are parsing parameters sent by the server; if false, we are
* parsing parameteres sent by the client.
@ -157,10 +157,10 @@ lsquic_tp_to_str (const struct transport_params *params, char *buf, size_t sz);
int
lsquic_tp_encode_27 (const struct transport_params *, int is_server,
unsigned char *buf, size_t bufsz);
unsigned char *const buf, size_t bufsz);
int
lsquic_tp_decode_27 (const unsigned char *buf, size_t bufsz,
lsquic_tp_decode_27 (const unsigned char *const buf, size_t bufsz,
int is_server,
struct transport_params *);

View file

@ -9,14 +9,15 @@
#include <string.h>
#include <time.h>
#ifndef WIN32
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <unistd.h>
#else
#include <vc_compat.h>
#include <ws2tcpip.h>
#endif
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#if !(defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) && defined(__APPLE__)
#include <mach/mach_time.h>

View file

@ -5,6 +5,10 @@
#include "lsquic_int_types.h"
#include "lsquic_version.h"
#if _MSC_VER
#include "vc_compat.h"
#endif
static const unsigned char version_tags[N_LSQVER][4] =
{