Skip to content

Commit

Permalink
Merge branch 'private-octopus:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
hfstco authored Jul 18, 2024
2 parents 3ec9c29 + 5796253 commit fdc15d7
Show file tree
Hide file tree
Showing 21 changed files with 261 additions and 211 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ else()
endif()

project(picoquic
VERSION 1.1.21.0
VERSION 1.1.21.2
DESCRIPTION "picoquic library"
LANGUAGES C CXX)

Expand Down
12 changes: 6 additions & 6 deletions loglib/logconvert.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ const char * ftype2str(picoquic_frame_type_enum_t ftype)
return "new_token";
case picoquic_frame_type_ack_ecn:
return "ack";
case picoquic_frame_type_ack_mp:
return "ack_mp";
case picoquic_frame_type_ack_mp_ecn:
return "ack_mp";
case picoquic_frame_type_mp_ack:
return "mp_ack";
case picoquic_frame_type_mp_ack_ecn:
return "mp_ack";
case picoquic_frame_type_retire_connection_id:
return "retire_connection_id";
case picoquic_frame_type_mp_retire_connection_id:
Expand All @@ -119,8 +119,8 @@ const char * ftype2str(picoquic_frame_type_enum_t ftype)
return "path_available";
case picoquic_frame_type_bdp:
return "bdp";
case picoquic_frame_type_max_paths:
return "max_paths";
case picoquic_frame_type_max_path_id:
return "max_path_id";
default:
return "unknown";
}
Expand Down
24 changes: 12 additions & 12 deletions loglib/qlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ int qlog_transport_extensions(FILE* f, bytestream* s, size_t tp_length)
case picoquic_tp_enable_bdp_frame:
qlog_vint_transport_extension(f, "enable_bdp_frame", s, extension_length);
break;
case picoquic_tp_initial_max_paths:
qlog_vint_transport_extension(f, "initial_max_paths", s, extension_length);
case picoquic_tp_initial_max_path_id:
qlog_vint_transport_extension(f, "initial_max_path_id", s, extension_length);
break;
default:
/* dump unknown extensions */
Expand Down Expand Up @@ -818,11 +818,11 @@ void qlog_path_available_frame(FILE* f, bytestream* s)
fprintf(f, ", \"sequence\": %"PRIu64, sequence);
}

void qlog_max_paths_frame(FILE* f, bytestream* s)
void qlog_max_path_id_frame(FILE* f, bytestream* s)
{
uint64_t max_paths = 0;
byteread_vint(s, &max_paths);
fprintf(f, ", \"max_paths\": %"PRIu64, max_paths);
uint64_t max_path_id = 0;
byteread_vint(s, &max_path_id);
fprintf(f, ", \"max_path_id\": %"PRIu64, max_path_id);
}

void qlog_reset_stream_frame(FILE* f, bytestream* s)
Expand Down Expand Up @@ -1052,7 +1052,7 @@ void qlog_ack_frame(uint64_t ftype, FILE * f, bytestream* s)
uint64_t ack_delay = 0;
uint64_t num = 0;
uint64_t path_id = 0;
if (ftype == picoquic_frame_type_ack_mp || ftype == picoquic_frame_type_ack_mp_ecn) {
if (ftype == picoquic_frame_type_mp_ack || ftype == picoquic_frame_type_mp_ack_ecn) {
byteread_vint(s, &path_id);
fprintf(f, ", \"path_id\": %"PRIu64"", path_id);
}
Expand Down Expand Up @@ -1083,7 +1083,7 @@ void qlog_ack_frame(uint64_t ftype, FILE * f, bytestream* s)
largest -= range + 1;
}
fprintf(f, "]");
if (ftype == picoquic_frame_type_ack_ecn || ftype == picoquic_frame_type_ack_mp_ecn) {
if (ftype == picoquic_frame_type_ack_ecn || ftype == picoquic_frame_type_mp_ack_ecn) {
char const* ecn_name[3] = { "ect0", "ect1", "ce" };
for (int ecnx = 0; ecnx < 3; ecnx++) {
uint64_t ecn_v = 0;
Expand Down Expand Up @@ -1198,8 +1198,8 @@ int qlog_packet_frame(bytestream * s, void * ptr)
break;
case picoquic_frame_type_ack:
case picoquic_frame_type_ack_ecn:
case picoquic_frame_type_ack_mp:
case picoquic_frame_type_ack_mp_ecn:
case picoquic_frame_type_mp_ack:
case picoquic_frame_type_mp_ack_ecn:
qlog_ack_frame(ftype, f, s);
break;
case picoquic_frame_type_reset_stream:
Expand Down Expand Up @@ -1276,8 +1276,8 @@ int qlog_packet_frame(bytestream * s, void * ptr)
case picoquic_frame_type_bdp:
qlog_bdp_frame(f, s);
break;
case picoquic_frame_type_max_paths:
qlog_max_paths_frame(f, s);
case picoquic_frame_type_max_path_id:
qlog_max_path_id_frame(f, s);
break;
default:
s->ptr = ptr_before_type;
Expand Down
104 changes: 52 additions & 52 deletions picoquic/frames.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ int picoquic_check_max_streams_frame_needs_repeat(picoquic_cnx_t* cnx, const uin
const uint8_t* p_last_byte, int* no_need_to_repeat);
int picoquic_path_available_or_standby_frame_need_repeat(picoquic_cnx_t* cnx, const uint8_t* bytes,
const uint8_t* bytes_max, int* no_need_to_repeat);
int picoquic_max_paths_frame_needs_repeat(picoquic_cnx_t* cnx, const uint8_t* bytes,
int picoquic_max_path_id_frame_needs_repeat(picoquic_cnx_t* cnx, const uint8_t* bytes,
const uint8_t* bytes_max, int* no_need_to_repeat);
int picoquic_process_ack_of_max_paths_frame(picoquic_cnx_t* cnx, const uint8_t* bytes,
int picoquic_process_ack_of_max_path_id_frame(picoquic_cnx_t* cnx, const uint8_t* bytes,
size_t bytes_max, size_t* consumed);

picoquic_stream_head_t* picoquic_create_missing_streams(picoquic_cnx_t* cnx, uint64_t stream_id, int is_remote)
Expand Down Expand Up @@ -463,7 +463,8 @@ const uint8_t* picoquic_decode_new_connection_id_frame(picoquic_cnx_t* cnx, cons
picoquic_frame_type_new_connection_id);
bytes = NULL;
}
else if (unique_path_id > cnx->max_paths_local) {
else if (unique_path_id >= cnx->max_path_id_local &&
cnx->is_multipath_enabled) {
/* Error -- the peer is not authorized to use this path ID */
picoquic_connection_error(cnx, PICOQUIC_TRANSPORT_MP_PROTOCOL_VIOLATION,
(is_mp) ? picoquic_frame_type_mp_new_connection_id : picoquic_frame_type_new_connection_id);
Expand Down Expand Up @@ -3037,8 +3038,8 @@ int picoquic_process_ack_of_ack_frame(
/* Forward declaration of skip frame function */
static const uint8_t* picoquic_skip_ack_frame_maybe_ecn(const uint8_t* bytes, const uint8_t* bytes_max, int is_ecn, int has_path);

/* For ACK_MP frame, ACK of ACK needs to retrieve the ACK context associated with the path */
int picoquic_process_ack_of_ack_mp_frame(
/* For MP_ACK frame, ACK of ACK needs to retrieve the ACK context associated with the path */
int picoquic_process_ack_of_mp_ack_frame(
picoquic_cnx_t * cnx, uint8_t* bytes, size_t bytes_max, size_t* consumed, int is_ecn)
{
int ret;
Expand Down Expand Up @@ -3286,8 +3287,8 @@ int picoquic_check_frame_needs_repeat(picoquic_cnx_t* cnx, const uint8_t* bytes,
case picoquic_frame_type_immediate_ack:
*no_need_to_repeat = 0;
break;
case picoquic_frame_type_ack_mp:
case picoquic_frame_type_ack_mp_ecn:
case picoquic_frame_type_mp_ack:
case picoquic_frame_type_mp_ack_ecn:
case picoquic_frame_type_time_stamp:
*no_need_to_repeat = 1;
break;
Expand All @@ -3300,8 +3301,8 @@ int picoquic_check_frame_needs_repeat(picoquic_cnx_t* cnx, const uint8_t* bytes,
(void)picoquic_path_available_or_standby_frame_need_repeat(cnx, bytes,
bytes + bytes_max, no_need_to_repeat);
break;
case picoquic_frame_type_max_paths:
(void)picoquic_max_paths_frame_needs_repeat(cnx, bytes,
case picoquic_frame_type_max_path_id:
(void)picoquic_max_path_id_frame_needs_repeat(cnx, bytes,
bytes + bytes_max, no_need_to_repeat);
break;
case picoquic_frame_type_mp_new_connection_id:
Expand Down Expand Up @@ -3388,12 +3389,12 @@ void picoquic_process_ack_of_frames(picoquic_cnx_t* cnx, picoquic_packet_t* p,
&p->bytes[byte_index], p->length - byte_index, &frame_length, 1);
byte_index += frame_length;
break;
case picoquic_frame_type_ack_mp:
ret = picoquic_process_ack_of_ack_mp_frame(cnx, &p->bytes[byte_index], p->length - byte_index, &frame_length, 0);
case picoquic_frame_type_mp_ack:
ret = picoquic_process_ack_of_mp_ack_frame(cnx, &p->bytes[byte_index], p->length - byte_index, &frame_length, 0);
byte_index += frame_length;
break;
case picoquic_frame_type_ack_mp_ecn:
ret = picoquic_process_ack_of_ack_mp_frame(cnx, &p->bytes[byte_index], p->length - byte_index, &frame_length, 1);
case picoquic_frame_type_mp_ack_ecn:
ret = picoquic_process_ack_of_mp_ack_frame(cnx, &p->bytes[byte_index], p->length - byte_index, &frame_length, 1);
byte_index += frame_length;
break;
case picoquic_frame_type_handshake_done:
Expand Down Expand Up @@ -3443,8 +3444,8 @@ void picoquic_process_ack_of_frames(picoquic_cnx_t* cnx, picoquic_packet_t* p,
ret = picoquic_process_ack_of_reset_stream_frame(cnx, &p->bytes[byte_index], p->length - byte_index, &frame_length);
byte_index += frame_length;
break;
case picoquic_frame_type_max_paths:
ret = picoquic_process_ack_of_max_paths_frame(cnx, &p->bytes[byte_index], p->length - byte_index, &frame_length);
case picoquic_frame_type_max_path_id:
ret = picoquic_process_ack_of_max_path_id_frame(cnx, &p->bytes[byte_index], p->length - byte_index, &frame_length);
byte_index += frame_length;
break;
default:
Expand Down Expand Up @@ -3726,7 +3727,7 @@ uint8_t* picoquic_format_ack_frame_in_context(picoquic_cnx_t* cnx, uint8_t* byte
uint8_t* after_stamp = bytes;
uint64_t ack_type_byte = (multipath_sequence == UINT64_MAX) ?
(((is_ecn) ? picoquic_frame_type_ack_ecn : picoquic_frame_type_ack)) :
(((is_ecn) ? picoquic_frame_type_ack_mp_ecn : picoquic_frame_type_ack_mp));
(((is_ecn) ? picoquic_frame_type_mp_ack_ecn : picoquic_frame_type_mp_ack));

/* Check that there something to acknowledge */
if (!picoquic_sack_list_is_empty(&ack_ctx->sack_list)) {
Expand Down Expand Up @@ -5452,103 +5453,102 @@ int picoquic_path_available_or_standby_frame_need_repeat(picoquic_cnx_t* cnx, co
}

/* MAX PATHS frame */

uint8_t* picoquic_format_max_paths_frame(
uint8_t* bytes, const uint8_t* bytes_max, uint64_t max_paths)
uint8_t* picoquic_format_max_path_id_frame(
uint8_t* bytes, const uint8_t* bytes_max, uint64_t max_path_id)
{
/* This code assumes that the frame type is already skipped */
if ((bytes = picoquic_frames_varint_encode(bytes, bytes_max, picoquic_frame_type_max_paths)) != NULL){
bytes = picoquic_frames_varint_encode(bytes, bytes_max, max_paths);
if ((bytes = picoquic_frames_varint_encode(bytes, bytes_max, picoquic_frame_type_max_path_id)) != NULL){
bytes = picoquic_frames_varint_encode(bytes, bytes_max, max_path_id);
}
return bytes;
}

int picoquic_queue_max_paths_frame(
int picoquic_queue_max_path_id_frame(
picoquic_cnx_t* cnx)
{
int ret = 0;
uint8_t frame_buffer[256];
int is_pure_ack = 0;
uint8_t* bytes_next = picoquic_format_max_paths_frame(
frame_buffer, frame_buffer + sizeof(frame_buffer), cnx->max_paths_local);
uint8_t* bytes_next = picoquic_format_max_path_id_frame(
frame_buffer, frame_buffer + sizeof(frame_buffer), cnx->max_path_id_local);
size_t consumed = bytes_next - frame_buffer;
ret = picoquic_queue_misc_frame(cnx, frame_buffer, consumed, is_pure_ack);
return ret;
}

const uint8_t* picoquic_skip_max_paths_frame(const uint8_t* bytes, const uint8_t* bytes_max)
const uint8_t* picoquic_skip_max_path_id_frame(const uint8_t* bytes, const uint8_t* bytes_max)
{
/* This code assumes that the frame type is already skipped */
bytes = picoquic_frames_varint_skip(bytes, bytes_max);
return bytes;
}

const uint8_t* picoquic_parse_max_paths_frame(const uint8_t* bytes, const uint8_t* bytes_max,
uint64_t* max_paths)
const uint8_t* picoquic_parse_max_path_id_frame(const uint8_t* bytes, const uint8_t* bytes_max,
uint64_t* max_path_id)
{
bytes = picoquic_frames_varint_decode(bytes, bytes_max, max_paths);
bytes = picoquic_frames_varint_decode(bytes, bytes_max, max_path_id);
return bytes;
}

const uint8_t* picoquic_decode_max_paths_frame(const uint8_t* bytes, const uint8_t* bytes_max,
const uint8_t* picoquic_decode_max_path_id_frame(const uint8_t* bytes, const uint8_t* bytes_max,
picoquic_cnx_t* cnx)
{
uint64_t max_paths;
uint64_t max_path_id;

/* This code assumes that the frame type is already skipped */

if (!cnx->is_multipath_enabled) {
/* Frame is unexpected */
picoquic_connection_error_ex(cnx, PICOQUIC_TRANSPORT_FRAME_FORMAT_ERROR,
picoquic_frame_type_max_paths, "unique path_id not negotiated");
picoquic_frame_type_max_path_id, "unique path_id not negotiated");
}
else if ((bytes = picoquic_parse_max_paths_frame(bytes, bytes_max, &max_paths)) == NULL) {
else if ((bytes = picoquic_parse_max_path_id_frame(bytes, bytes_max, &max_path_id)) == NULL) {
/* Bad frame encoding */
picoquic_connection_error_ex(cnx, PICOQUIC_TRANSPORT_FRAME_FORMAT_ERROR,
picoquic_frame_type_max_paths, "bad max paths frame");
picoquic_frame_type_max_path_id, "bad max paths frame");
}
else {
/* process the max paths frame */
if (cnx->max_paths_remote < max_paths) {
cnx->max_paths_remote = max_paths;
if (cnx->max_path_id_remote < max_path_id) {
cnx->max_path_id_remote = max_path_id;
}
}
return bytes;
}

int picoquic_max_paths_frame_needs_repeat(picoquic_cnx_t* cnx, const uint8_t* bytes,
int picoquic_max_path_id_frame_needs_repeat(picoquic_cnx_t* cnx, const uint8_t* bytes,
const uint8_t* bytes_max, int* no_need_to_repeat)
{
int ret = 0;
uint64_t max_paths = 0;
uint64_t max_path_id = 0;

*no_need_to_repeat = 0;

if ((bytes = picoquic_parse_max_paths_frame(bytes, bytes_max, &max_paths)) == NULL){
if ((bytes = picoquic_parse_max_path_id_frame(bytes, bytes_max, &max_path_id)) == NULL){
/* Malformed frame, do not retransmit */
*no_need_to_repeat = 1;
}
else {
/* check whether this is the last frame sent, and whether we already
* have received an ack */
if (max_paths < cnx->max_paths_local || max_paths <= cnx->max_paths_acknowledged){
if (max_path_id < cnx->max_path_id_local || max_path_id <= cnx->max_path_id_acknowledged){
*no_need_to_repeat = 1;
}
}
return ret;
}


int picoquic_process_ack_of_max_paths_frame(picoquic_cnx_t* cnx, const uint8_t* bytes,
int picoquic_process_ack_of_max_path_id_frame(picoquic_cnx_t* cnx, const uint8_t* bytes,
size_t bytes_max, size_t* consumed)
{
int ret = 0;
uint64_t max_paths = 0;
uint64_t max_path_id = 0;

const uint8_t * bytes_next = picoquic_parse_max_paths_frame(bytes, bytes + bytes_max, &max_paths);
const uint8_t * bytes_next = picoquic_parse_max_path_id_frame(bytes, bytes + bytes_max, &max_path_id);

if (bytes_next != NULL && cnx->max_paths_acknowledged < max_paths){
cnx->max_paths_acknowledged = max_paths;
if (bytes_next != NULL && cnx->max_path_id_acknowledged < max_path_id){
cnx->max_path_id_acknowledged = max_path_id;
*consumed = bytes_next - bytes;
}
else {
Expand Down Expand Up @@ -5884,7 +5884,7 @@ int picoquic_decode_frames(picoquic_cnx_t* cnx, picoquic_path_t * path_x, const
case picoquic_frame_type_time_stamp:
bytes = picoquic_decode_time_stamp_frame(bytes, bytes_max, cnx, &packet_data);
break;
case picoquic_frame_type_ack_mp: {
case picoquic_frame_type_mp_ack: {
if (epoch == picoquic_epoch_0rtt) {
DBG_PRINTF("Ack frame (0x%x) not expected in 0-RTT packet", first_byte);
picoquic_connection_error(cnx, PICOQUIC_TRANSPORT_PROTOCOL_VIOLATION, first_byte);
Expand All @@ -5894,7 +5894,7 @@ int picoquic_decode_frames(picoquic_cnx_t* cnx, picoquic_path_t * path_x, const
bytes = picoquic_decode_ack_frame(cnx, bytes0, bytes_max, current_time, epoch, 0, 1, &packet_data);
break;
}
case picoquic_frame_type_ack_mp_ecn: {
case picoquic_frame_type_mp_ack_ecn: {
if (epoch == picoquic_epoch_0rtt) {
DBG_PRINTF("Ack-ECN frame (0x%x) not expected in 0-RTT packet", first_byte);
picoquic_connection_error(cnx, PICOQUIC_TRANSPORT_PROTOCOL_VIOLATION, first_byte);
Expand All @@ -5913,8 +5913,8 @@ int picoquic_decode_frames(picoquic_cnx_t* cnx, picoquic_path_t * path_x, const
bytes = picoquic_decode_path_available_or_standby_frame(bytes, bytes_max, frame_id64, cnx, current_time);
ack_needed = 1;
break;
case picoquic_frame_type_max_paths:
bytes = picoquic_decode_max_paths_frame(bytes, bytes_max, cnx);
case picoquic_frame_type_max_path_id:
bytes = picoquic_decode_max_path_id_frame(bytes, bytes_max, cnx);
ack_needed = 1;
break;
case picoquic_frame_type_mp_new_connection_id:
Expand Down Expand Up @@ -6231,10 +6231,10 @@ int picoquic_skip_frame(const uint8_t* bytes, size_t bytes_maxsize, size_t* cons
case picoquic_frame_type_time_stamp:
bytes = picoquic_skip_time_stamp_frame(bytes, bytes_max);
break;
case picoquic_frame_type_ack_mp:
case picoquic_frame_type_mp_ack:
bytes = picoquic_skip_ack_frame_maybe_ecn(bytes_before_type, bytes_max, 0, 1);
break;
case picoquic_frame_type_ack_mp_ecn:
case picoquic_frame_type_mp_ack_ecn:
bytes = picoquic_skip_ack_frame_maybe_ecn(bytes_before_type, bytes_max, 1, 1);
break;
case picoquic_frame_type_path_abandon:
Expand All @@ -6246,8 +6246,8 @@ int picoquic_skip_frame(const uint8_t* bytes, size_t bytes_maxsize, size_t* cons
bytes = picoquic_skip_path_available_or_standby_frame(bytes, bytes_max);
*pure_ack = 0;
break;
case picoquic_frame_type_max_paths:
bytes = picoquic_skip_max_paths_frame(bytes, bytes_max);
case picoquic_frame_type_max_path_id:
bytes = picoquic_skip_max_path_id_frame(bytes, bytes_max);
*pure_ack = 0;
break;
case picoquic_frame_type_bdp:
Expand Down
Loading

0 comments on commit fdc15d7

Please sign in to comment.