Latest changes

- Add support for Q041; drop support for Q040
This commit is contained in:
Dmitri Tikhonov 2017-09-28 14:50:30 -04:00
parent fc214ce40d
commit 1b97e4af1f
22 changed files with 87 additions and 94 deletions

View file

@ -8,7 +8,7 @@ SET(lsquic_STAT_SRCS
lsquic_parse_gquic_common.c
lsquic_parse_gquic_le.c
lsquic_parse_gquic_be.c
lsquic_parse_gquic_Q040.c
lsquic_parse_gquic_Q041.c
lsquic_packet_in.c
lsquic_packet_out.c
lsquic_crypto.c

View file

@ -20,11 +20,6 @@
#include <unistd.h>
#include <netdb.h>
#ifndef NDEBUG
#include <sys/types.h>
#include <regex.h> /* For code that loses packets */
#endif
#include "lsquic.h"

View file

@ -158,7 +158,7 @@ struct parse_funcs
extern const struct parse_funcs lsquic_parse_funcs_gquic_le;
/* Q039 and later are big-endian: */
extern const struct parse_funcs lsquic_parse_funcs_gquic_Q039;
extern const struct parse_funcs lsquic_parse_funcs_gquic_Q040;
extern const struct parse_funcs lsquic_parse_funcs_gquic_Q041;
#define select_pf_by_ver(ver) ( \
((1 << (ver)) & ((1 << LSQVER_035) | \
@ -166,7 +166,7 @@ extern const struct parse_funcs lsquic_parse_funcs_gquic_Q040;
? &lsquic_parse_funcs_gquic_le : \
((1 << (ver)) & (1 << LSQVER_039)) \
? &lsquic_parse_funcs_gquic_Q039 \
: &lsquic_parse_funcs_gquic_Q040)
: &lsquic_parse_funcs_gquic_Q041)
/* This function is QUIC-version independent */
int
@ -177,7 +177,7 @@ enum QUIC_FRAME_TYPE
parse_frame_type_gquic_Q035_thru_Q039 (unsigned char first_byte);
enum QUIC_FRAME_TYPE
parse_frame_type_gquic_Q040 (unsigned char first_byte);
parse_frame_type_gquic_Q041 (unsigned char first_byte);
unsigned
parse_stream_frame_header_sz_gquic (unsigned char type);

View file

@ -101,12 +101,6 @@ gquic_ietf_parse_stream_frame (const unsigned char *buf, size_t rem_packet_sz,
stream_frame->data_frame.df_fin = !!(type & 0x20);
if (data_len)
{
READ_UINT(stream_frame->data_frame.df_size, 16, p, data_len);
p += data_len;
}
READ_UINT(stream_frame->stream_id, 32, p, stream_id_len);
p += stream_id_len;
@ -115,6 +109,8 @@ gquic_ietf_parse_stream_frame (const unsigned char *buf, size_t rem_packet_sz,
if (data_len)
{
READ_UINT(stream_frame->data_frame.df_size, 16, p, data_len);
p += data_len;
CHECK_SPACE(stream_frame->data_frame.df_size, p, pend);
stream_frame->data_frame.df_data = p;
p += stream_frame->data_frame.df_size;
@ -198,8 +194,6 @@ gquic_ietf_gen_stream_frame (unsigned char *buf, size_t buf_len, uint32_t stream
CHECK_SPACE(1 + olen + slen + dlen +
+ 1 /* We need to write at least 1 byte */, buf, buf + buf_len);
p += dlen; /* Save room for data length */
#if __BYTE_ORDER == __LITTLE_ENDIAN
stream_id = bswap_32(stream_id);
#endif
@ -213,7 +207,7 @@ gquic_ietf_gen_stream_frame (unsigned char *buf, size_t buf_len, uint32_t stream
p += olen;
/* Read as much as we can */
nr = gsf_read(stream, p, n_avail, &fin);
nr = gsf_read(stream, p + dlen, n_avail, &fin);
assert(nr != 0);
if (dlen)
@ -222,17 +216,15 @@ gquic_ietf_gen_stream_frame (unsigned char *buf, size_t buf_len, uint32_t stream
#if __BYTE_ORDER == __LITTLE_ENDIAN
nr_copy = bswap_16(nr_copy);
#endif
memcpy(p - slen - olen - 2, &nr_copy, 2);
memcpy(p, &nr_copy, 2);
}
p += nr;
p += dlen + nr;
}
else
{
dlen = 2;
CHECK_SPACE(1 + slen + olen + 2, buf, buf + buf_len);
memset(p, 0, 2);
p += 2;
#if __BYTE_ORDER == __LITTLE_ENDIAN
stream_id = bswap_32(stream_id);
#endif
@ -243,6 +235,8 @@ gquic_ietf_gen_stream_frame (unsigned char *buf, size_t buf_len, uint32_t stream
#endif
memcpy(p, (unsigned char *) &offset + 8 - olen, olen);
p += olen;
memset(p, 0, 2);
p += 2;
}
/* Convert slen to bit representation: 0 - 3: */
@ -279,7 +273,7 @@ gquic_ietf_parse_ack_high (const unsigned char *buf, size_t buf_len)
type = buf[0];
largest_obs_len = twobit_to_1248((type >> 2) & 3);
n_blocks_len = !!(type & 0x10);
assert(parse_frame_type_gquic_Q040(type) == QUIC_FRAME_ACK);
assert(parse_frame_type_gquic_Q041(type) == QUIC_FRAME_ACK);
assert(buf_len >= 1 + n_blocks_len + 1 + largest_obs_len);
READ_UINT(packno, 64, buf + 1 + n_blocks_len + 1, largest_obs_len);
return packno;
@ -540,7 +534,7 @@ gquic_ietf_gen_ack_frame (unsigned char *outbuf, size_t outbuf_sz,
}
const struct parse_funcs lsquic_parse_funcs_gquic_Q040 =
const struct parse_funcs lsquic_parse_funcs_gquic_Q041 =
{
.pf_gen_ver_nego_pkt = gquic_be_gen_ver_nego_pkt,
.pf_gen_reg_pkt_header = gquic_be_gen_reg_pkt_header,
@ -570,5 +564,5 @@ const struct parse_funcs lsquic_parse_funcs_gquic_Q040 =
.pf_write_float_time16 = gquic_be_write_float_time16,
.pf_read_float_time16 = gquic_be_read_float_time16,
#endif
.pf_parse_frame_type = parse_frame_type_gquic_Q040,
.pf_parse_frame_type = parse_frame_type_gquic_Q041,
};

View file

@ -389,7 +389,7 @@ static const enum QUIC_FRAME_TYPE byte2frame_type_Q035_thru_Q039[0x100] =
};
static const enum QUIC_FRAME_TYPE byte2frame_type_Q040[0x100] =
static const enum QUIC_FRAME_TYPE byte2frame_type_Q041[0x100] =
{
[0x00] = QUIC_FRAME_PADDING,
[0x01] = QUIC_FRAME_RST_STREAM,
@ -658,9 +658,9 @@ parse_frame_type_gquic_Q035_thru_Q039 (unsigned char b)
enum QUIC_FRAME_TYPE
parse_frame_type_gquic_Q040 (unsigned char b)
parse_frame_type_gquic_Q041 (unsigned char b)
{
return byte2frame_type_Q040[b];
return byte2frame_type_Q041[b];
}

View file

@ -12,7 +12,7 @@ static const unsigned char version_tags[N_LSQVER][4] =
[LSQVER_037] = { 'Q', '0', '3', '7', },
[LSQVER_038] = { 'Q', '0', '3', '8', },
[LSQVER_039] = { 'Q', '0', '3', '9', },
[LSQVER_040] = { 'Q', '0', '4', '0', },
[LSQVER_041] = { 'Q', '0', '4', '1', },
};
@ -61,7 +61,7 @@ const char *const lsquic_ver2str[N_LSQVER] = {
[LSQVER_037] = "Q037",
[LSQVER_038] = "Q038",
[LSQVER_039] = "Q039",
[LSQVER_040] = "Q040",
[LSQVER_041] = "Q041",
};