CLEANUP: quic: rename frame variables

Rename all frame variables with the suffix _frm. This helps to
differentiate frame instances from other internal objects.

This should be backported up to 2.7.
This commit is contained in:
Amaury Denoyelle 2023-04-24 15:32:23 +02:00
parent 888c5f283a
commit d5f03cd576
5 changed files with 292 additions and 292 deletions

View File

@ -199,13 +199,13 @@ static inline void free_quic_conn_cids(struct quic_conn *conn)
static inline void quic_connection_id_to_frm_cpy(struct quic_frame *dst, static inline void quic_connection_id_to_frm_cpy(struct quic_frame *dst,
struct quic_connection_id *src) struct quic_connection_id *src)
{ {
struct qf_new_connection_id *to = &dst->new_connection_id; struct qf_new_connection_id *ncid_frm = &dst->new_connection_id;
to->seq_num = src->seq_num.key; ncid_frm->seq_num = src->seq_num.key;
to->retire_prior_to = src->retire_prior_to; ncid_frm->retire_prior_to = src->retire_prior_to;
to->cid.len = src->cid.len; ncid_frm->cid.len = src->cid.len;
to->cid.data = src->cid.data; ncid_frm->cid.data = src->cid.data;
to->stateless_reset_token = src->stateless_reset_token; ncid_frm->stateless_reset_token = src->stateless_reset_token;
} }
/* Return a 32-bits integer in <val> from QUIC packet with <buf> as address. /* Return a 32-bits integer in <val> from QUIC packet with <buf> as address.

View File

@ -278,18 +278,18 @@ static inline void qc_frm_free(struct quic_frame **frm)
/* Move forward <strm> STREAM frame by <data> bytes. */ /* Move forward <strm> STREAM frame by <data> bytes. */
static inline void qc_stream_frm_mv_fwd(struct quic_frame *frm, uint64_t data) static inline void qc_stream_frm_mv_fwd(struct quic_frame *frm, uint64_t data)
{ {
struct qf_stream *strm = &frm->stream; struct qf_stream *strm_frm = &frm->stream;
struct buffer cf_buf; struct buffer cf_buf;
/* Set offset bit if not already there. */ /* Set offset bit if not already there. */
strm->offset.key += data; strm_frm->offset.key += data;
frm->type |= QUIC_STREAM_FRAME_TYPE_OFF_BIT; frm->type |= QUIC_STREAM_FRAME_TYPE_OFF_BIT;
strm->len -= data; strm_frm->len -= data;
cf_buf = b_make(b_orig(strm->buf), cf_buf = b_make(b_orig(strm_frm->buf),
b_size(strm->buf), b_size(strm_frm->buf),
(char *)strm->data - b_orig(strm->buf), 0); (char *)strm_frm->data - b_orig(strm_frm->buf), 0);
strm->data = (unsigned char *)b_peek(&cf_buf, data); strm_frm->data = (unsigned char *)b_peek(&cf_buf, data);
} }
#endif /* USE_QUIC */ #endif /* USE_QUIC */

View File

@ -576,11 +576,11 @@ static void quic_trace(enum trace_level level, uint64_t mask, const struct trace
} }
if (mask & QUIC_EV_CONN_ACKSTRM) { if (mask & QUIC_EV_CONN_ACKSTRM) {
const struct qf_stream *s = a2; const struct qf_stream *strm_frm = a2;
const struct qc_stream_desc *stream = a3; const struct qc_stream_desc *stream = a3;
if (s) if (strm_frm)
chunk_appendf(&trace_buf, " off=%llu len=%llu", (ull)s->offset.key, (ull)s->len); chunk_appendf(&trace_buf, " off=%llu len=%llu", (ull)strm_frm->offset.key, (ull)strm_frm->len);
if (stream) if (stream)
chunk_appendf(&trace_buf, " ack_offset=%llu", (ull)stream->ack_offset); chunk_appendf(&trace_buf, " ack_offset=%llu", (ull)stream->ack_offset);
} }
@ -1737,13 +1737,13 @@ static int quic_stream_try_to_consume(struct quic_conn *qc,
ret = 0; ret = 0;
frm_node = eb64_first(&stream->acked_frms); frm_node = eb64_first(&stream->acked_frms);
while (frm_node) { while (frm_node) {
struct qf_stream *strm; struct qf_stream *strm_frm;
struct quic_frame *frm; struct quic_frame *frm;
size_t offset, len; size_t offset, len;
strm = eb64_entry(frm_node, struct qf_stream, offset); strm_frm = eb64_entry(frm_node, struct qf_stream, offset);
offset = strm->offset.key; offset = strm_frm->offset.key;
len = strm->len; len = strm_frm->len;
if (offset > stream->ack_offset) if (offset > stream->ack_offset)
break; break;
@ -1751,7 +1751,7 @@ static int quic_stream_try_to_consume(struct quic_conn *qc,
if (qc_stream_desc_ack(&stream, offset, len)) { if (qc_stream_desc_ack(&stream, offset, len)) {
/* cf. next comment : frame may be freed at this stage. */ /* cf. next comment : frame may be freed at this stage. */
TRACE_DEVEL("stream consumed", QUIC_EV_CONN_ACKSTRM, TRACE_DEVEL("stream consumed", QUIC_EV_CONN_ACKSTRM,
qc, stream ? strm : NULL, stream); qc, stream ? strm_frm : NULL, stream);
ret = 1; ret = 1;
} }
@ -1766,9 +1766,9 @@ static int quic_stream_try_to_consume(struct quic_conn *qc,
} }
frm_node = eb64_next(frm_node); frm_node = eb64_next(frm_node);
eb64_delete(&strm->offset); eb64_delete(&strm_frm->offset);
frm = container_of(strm, struct quic_frame, stream); frm = container_of(strm_frm, struct quic_frame, stream);
qc_release_frm(qc, frm); qc_release_frm(qc, frm);
} }
@ -2209,7 +2209,7 @@ static inline int qc_parse_ack_frm(struct quic_conn *qc,
unsigned int *rtt_sample, unsigned int *rtt_sample,
const unsigned char **pos, const unsigned char *end) const unsigned char **pos, const unsigned char *end)
{ {
struct qf_ack *ack = &frm->ack; struct qf_ack *ack_frm = &frm->ack;
uint64_t smallest, largest; uint64_t smallest, largest;
struct eb_root *pkts; struct eb_root *pkts;
struct eb64_node *largest_node; struct eb64_node *largest_node;
@ -2220,26 +2220,26 @@ static inline int qc_parse_ack_frm(struct quic_conn *qc,
TRACE_ENTER(QUIC_EV_CONN_PRSAFRM, qc); TRACE_ENTER(QUIC_EV_CONN_PRSAFRM, qc);
if (ack->largest_ack > qel->pktns->tx.next_pn) { if (ack_frm->largest_ack > qel->pktns->tx.next_pn) {
TRACE_DEVEL("ACK for not sent packet", QUIC_EV_CONN_PRSAFRM, TRACE_DEVEL("ACK for not sent packet", QUIC_EV_CONN_PRSAFRM,
qc, NULL, &ack->largest_ack); qc, NULL, &ack_frm->largest_ack);
goto err; goto err;
} }
if (ack->first_ack_range > ack->largest_ack) { if (ack_frm->first_ack_range > ack_frm->largest_ack) {
TRACE_DEVEL("too big first ACK range", QUIC_EV_CONN_PRSAFRM, TRACE_DEVEL("too big first ACK range", QUIC_EV_CONN_PRSAFRM,
qc, NULL, &ack->first_ack_range); qc, NULL, &ack_frm->first_ack_range);
goto err; goto err;
} }
largest = ack->largest_ack; largest = ack_frm->largest_ack;
smallest = largest - ack->first_ack_range; smallest = largest - ack_frm->first_ack_range;
pkts = &qel->pktns->tx.pkts; pkts = &qel->pktns->tx.pkts;
pkt_flags = 0; pkt_flags = 0;
largest_node = NULL; largest_node = NULL;
time_sent = 0; time_sent = 0;
if ((int64_t)ack->largest_ack > qel->pktns->rx.largest_acked_pn) { if ((int64_t)ack_frm->largest_ack > qel->pktns->rx.largest_acked_pn) {
largest_node = eb64_lookup(pkts, largest); largest_node = eb64_lookup(pkts, largest);
if (!largest_node) { if (!largest_node) {
TRACE_DEVEL("Largest acked packet not found", TRACE_DEVEL("Largest acked packet not found",
@ -2258,7 +2258,7 @@ static inline int qc_parse_ack_frm(struct quic_conn *qc,
qc_ackrng_pkts(qc, pkts, &pkt_flags, &newly_acked_pkts, qc_ackrng_pkts(qc, pkts, &pkt_flags, &newly_acked_pkts,
largest_node, largest, smallest); largest_node, largest, smallest);
if (!ack->ack_range_num--) if (!ack_frm->ack_range_num--)
break; break;
if (!quic_dec_int(&gap, pos, end)) { if (!quic_dec_int(&gap, pos, end)) {
@ -2295,7 +2295,7 @@ static inline int qc_parse_ack_frm(struct quic_conn *qc,
if (time_sent && (pkt_flags & QUIC_FL_TX_PACKET_ACK_ELICITING)) { if (time_sent && (pkt_flags & QUIC_FL_TX_PACKET_ACK_ELICITING)) {
*rtt_sample = tick_remain(time_sent, now_ms); *rtt_sample = tick_remain(time_sent, now_ms);
qel->pktns->rx.largest_acked_pn = ack->largest_ack; qel->pktns->rx.largest_acked_pn = ack_frm->largest_ack;
} }
if (!LIST_ISEMPTY(&newly_acked_pkts)) { if (!LIST_ISEMPTY(&newly_acked_pkts)) {
@ -2903,15 +2903,15 @@ static struct ncbuf *quic_get_ncbuf(struct ncbuf *ncbuf)
* CRYPTO data. * CRYPTO data.
*/ */
static int qc_handle_crypto_frm(struct quic_conn *qc, static int qc_handle_crypto_frm(struct quic_conn *qc,
struct qf_crypto *frm, struct quic_rx_packet *pkt, struct qf_crypto *crypto_frm, struct quic_rx_packet *pkt,
struct quic_enc_level *qel, int *fast_retrans) struct quic_enc_level *qel, int *fast_retrans)
{ {
int ret = 0; int ret = 0;
enum ncb_ret ncb_ret; enum ncb_ret ncb_ret;
/* XXX TO DO: <cfdebug> is used only for the traces. */ /* XXX TO DO: <cfdebug> is used only for the traces. */
struct quic_rx_crypto_frm cfdebug = { struct quic_rx_crypto_frm cfdebug = {
.offset_node.key = frm->offset, .offset_node.key = crypto_frm->offset,
.len = frm->len, .len = crypto_frm->len,
}; };
struct quic_cstream *cstream = qel->cstream; struct quic_cstream *cstream = qel->cstream;
struct ncbuf *ncbuf = &qel->cstream->rx.ncbuf; struct ncbuf *ncbuf = &qel->cstream->rx.ncbuf;
@ -2923,10 +2923,10 @@ static int qc_handle_crypto_frm(struct quic_conn *qc,
goto done; goto done;
} }
if (unlikely(frm->offset < cstream->rx.offset)) { if (unlikely(crypto_frm->offset < cstream->rx.offset)) {
size_t diff; size_t diff;
if (frm->offset + frm->len <= cstream->rx.offset) { if (crypto_frm->offset + crypto_frm->len <= cstream->rx.offset) {
/* Nothing to do */ /* Nothing to do */
TRACE_PROTO("Already received CRYPTO data", TRACE_PROTO("Already received CRYPTO data",
QUIC_EV_CONN_RXPKT, qc, pkt, &cfdebug); QUIC_EV_CONN_RXPKT, qc, pkt, &cfdebug);
@ -2939,20 +2939,20 @@ static int qc_handle_crypto_frm(struct quic_conn *qc,
TRACE_PROTO("Partially already received CRYPTO data", TRACE_PROTO("Partially already received CRYPTO data",
QUIC_EV_CONN_RXPKT, qc, pkt, &cfdebug); QUIC_EV_CONN_RXPKT, qc, pkt, &cfdebug);
diff = cstream->rx.offset - frm->offset; diff = cstream->rx.offset - crypto_frm->offset;
frm->len -= diff; crypto_frm->len -= diff;
frm->data += diff; crypto_frm->data += diff;
frm->offset = cstream->rx.offset; crypto_frm->offset = cstream->rx.offset;
} }
if (frm->offset == cstream->rx.offset && ncb_is_empty(ncbuf)) { if (crypto_frm->offset == cstream->rx.offset && ncb_is_empty(ncbuf)) {
if (!qc_provide_cdata(qel, qc->xprt_ctx, frm->data, frm->len, if (!qc_provide_cdata(qel, qc->xprt_ctx, crypto_frm->data, crypto_frm->len,
pkt, &cfdebug)) { pkt, &cfdebug)) {
// trace already emitted by function above // trace already emitted by function above
goto leave; goto leave;
} }
cstream->rx.offset += frm->len; cstream->rx.offset += crypto_frm->len;
TRACE_DEVEL("increment crypto level offset", QUIC_EV_CONN_PHPKTS, qc, qel); TRACE_DEVEL("increment crypto level offset", QUIC_EV_CONN_PHPKTS, qc, qel);
goto done; goto done;
} }
@ -2963,9 +2963,9 @@ static int qc_handle_crypto_frm(struct quic_conn *qc,
goto leave; goto leave;
} }
/* frm->offset > cstream-trx.offset */ /* crypto_frm->offset > cstream-trx.offset */
ncb_ret = ncb_add(ncbuf, frm->offset - cstream->rx.offset, ncb_ret = ncb_add(ncbuf, crypto_frm->offset - cstream->rx.offset,
(const char *)frm->data, frm->len, NCB_ADD_COMPARE); (const char *)crypto_frm->data, crypto_frm->len, NCB_ADD_COMPARE);
if (ncb_ret != NCB_RET_OK) { if (ncb_ret != NCB_RET_OK) {
if (ncb_ret == NCB_RET_DATA_REJ) { if (ncb_ret == NCB_RET_DATA_REJ) {
TRACE_ERROR("overlapping data rejected", QUIC_EV_CONN_PRSHPKT, qc); TRACE_ERROR("overlapping data rejected", QUIC_EV_CONN_PRSHPKT, qc);
@ -3024,7 +3024,7 @@ static int qc_handle_retire_connection_id_frm(struct quic_conn *qc,
struct quic_connection_id **to_retire) struct quic_connection_id **to_retire)
{ {
int ret = 0; int ret = 0;
struct qf_retire_connection_id *rcid = &frm->retire_connection_id; struct qf_retire_connection_id *rcid_frm = &frm->retire_connection_id;
struct eb64_node *node; struct eb64_node *node;
struct quic_connection_id *conn_id; struct quic_connection_id *conn_id;
@ -3035,7 +3035,7 @@ static int qc_handle_retire_connection_id_frm(struct quic_conn *qc,
* than any previously sent to the peer MUST be treated as a connection error * than any previously sent to the peer MUST be treated as a connection error
* of type PROTOCOL_VIOLATION. * of type PROTOCOL_VIOLATION.
*/ */
if (rcid->seq_num >= qc->next_cid_seq_num) { if (rcid_frm->seq_num >= qc->next_cid_seq_num) {
TRACE_PROTO("CID seq. number too big", QUIC_EV_CONN_PSTRM, qc, frm); TRACE_PROTO("CID seq. number too big", QUIC_EV_CONN_PSTRM, qc, frm);
goto protocol_violation; goto protocol_violation;
} }
@ -3045,7 +3045,7 @@ static int qc_handle_retire_connection_id_frm(struct quic_conn *qc,
* the Destination Connection ID field of the packet in which the frame is contained. * the Destination Connection ID field of the packet in which the frame is contained.
* The peer MAY treat this as a connection error of type PROTOCOL_VIOLATION. * The peer MAY treat this as a connection error of type PROTOCOL_VIOLATION.
*/ */
node = eb64_lookup(&qc->cids, rcid->seq_num); node = eb64_lookup(&qc->cids, rcid_frm->seq_num);
if (!node) { if (!node) {
TRACE_PROTO("CID already retired", QUIC_EV_CONN_PSTRM, qc, frm); TRACE_PROTO("CID already retired", QUIC_EV_CONN_PSTRM, qc, frm);
goto out; goto out;
@ -3154,16 +3154,16 @@ static int qc_parse_pkt_frms(struct quic_conn *qc, struct quic_rx_packet *pkt,
} }
case QUIC_FT_RESET_STREAM: case QUIC_FT_RESET_STREAM:
if (qc->mux_state == QC_MUX_READY) { if (qc->mux_state == QC_MUX_READY) {
struct qf_reset_stream *rs = &frm.reset_stream; struct qf_reset_stream *rs_frm = &frm.reset_stream;
qcc_recv_reset_stream(qc->qcc, rs->id, rs->app_error_code, rs->final_size); qcc_recv_reset_stream(qc->qcc, rs_frm->id, rs_frm->app_error_code, rs_frm->final_size);
} }
break; break;
case QUIC_FT_STOP_SENDING: case QUIC_FT_STOP_SENDING:
{ {
struct qf_stop_sending *stop_sending = &frm.stop_sending; struct qf_stop_sending *ss_frm = &frm.stop_sending;
if (qc->mux_state == QC_MUX_READY) { if (qc->mux_state == QC_MUX_READY) {
if (qcc_recv_stop_sending(qc->qcc, stop_sending->id, if (qcc_recv_stop_sending(qc->qcc, ss_frm->id,
stop_sending->app_error_code)) { ss_frm->app_error_code)) {
TRACE_ERROR("qcc_recv_stop_sending() failed", QUIC_EV_CONN_PRSHPKT, qc); TRACE_ERROR("qcc_recv_stop_sending() failed", QUIC_EV_CONN_PRSHPKT, qc);
goto leave; goto leave;
} }
@ -3176,19 +3176,19 @@ static int qc_parse_pkt_frms(struct quic_conn *qc, struct quic_rx_packet *pkt,
break; break;
case QUIC_FT_STREAM_8 ... QUIC_FT_STREAM_F: case QUIC_FT_STREAM_8 ... QUIC_FT_STREAM_F:
{ {
struct qf_stream *stream = &frm.stream; struct qf_stream *strm_frm = &frm.stream;
unsigned nb_streams = qc->rx.strms[qcs_id_type(stream->id)].nb_streams; unsigned nb_streams = qc->rx.strms[qcs_id_type(strm_frm->id)].nb_streams;
const char fin = frm.type & QUIC_STREAM_FRAME_TYPE_FIN_BIT; const char fin = frm.type & QUIC_STREAM_FRAME_TYPE_FIN_BIT;
/* The upper layer may not be allocated. */ /* The upper layer may not be allocated. */
if (qc->mux_state != QC_MUX_READY) { if (qc->mux_state != QC_MUX_READY) {
if ((stream->id >> QCS_ID_TYPE_SHIFT) < nb_streams) { if ((strm_frm->id >> QCS_ID_TYPE_SHIFT) < nb_streams) {
TRACE_DATA("Already closed stream", QUIC_EV_CONN_PRSHPKT, qc); TRACE_DATA("Already closed stream", QUIC_EV_CONN_PRSHPKT, qc);
} }
else { else {
TRACE_DEVEL("No mux for new stream", QUIC_EV_CONN_PRSHPKT, qc); TRACE_DEVEL("No mux for new stream", QUIC_EV_CONN_PRSHPKT, qc);
if (qc->app_ops == &h3_ops) { if (qc->app_ops == &h3_ops) {
if (!qc_h3_request_reject(qc, stream->id)) { if (!qc_h3_request_reject(qc, strm_frm->id)) {
TRACE_ERROR("error on request rejection", QUIC_EV_CONN_PRSHPKT, qc); TRACE_ERROR("error on request rejection", QUIC_EV_CONN_PRSHPKT, qc);
/* This packet will not be acknowledged */ /* This packet will not be acknowledged */
goto leave; goto leave;
@ -3203,7 +3203,7 @@ static int qc_parse_pkt_frms(struct quic_conn *qc, struct quic_rx_packet *pkt,
break; break;
} }
if (!qc_handle_strm_frm(pkt, stream, qc, fin)) { if (!qc_handle_strm_frm(pkt, strm_frm, qc, fin)) {
TRACE_ERROR("qc_handle_strm_frm() failed", QUIC_EV_CONN_PRSHPKT, qc); TRACE_ERROR("qc_handle_strm_frm() failed", QUIC_EV_CONN_PRSHPKT, qc);
goto leave; goto leave;
} }
@ -3212,15 +3212,15 @@ static int qc_parse_pkt_frms(struct quic_conn *qc, struct quic_rx_packet *pkt,
} }
case QUIC_FT_MAX_DATA: case QUIC_FT_MAX_DATA:
if (qc->mux_state == QC_MUX_READY) { if (qc->mux_state == QC_MUX_READY) {
struct qf_max_data *data = &frm.max_data; struct qf_max_data *md_frm = &frm.max_data;
qcc_recv_max_data(qc->qcc, data->max_data); qcc_recv_max_data(qc->qcc, md_frm->max_data);
} }
break; break;
case QUIC_FT_MAX_STREAM_DATA: case QUIC_FT_MAX_STREAM_DATA:
if (qc->mux_state == QC_MUX_READY) { if (qc->mux_state == QC_MUX_READY) {
struct qf_max_stream_data *data = &frm.max_stream_data; struct qf_max_stream_data *msd_frm = &frm.max_stream_data;
if (qcc_recv_max_stream_data(qc->qcc, data->id, if (qcc_recv_max_stream_data(qc->qcc, msd_frm->id,
data->max_stream_data)) { msd_frm->max_stream_data)) {
TRACE_ERROR("qcc_recv_max_stream_data() failed", QUIC_EV_CONN_PRSHPKT, qc); TRACE_ERROR("qcc_recv_max_stream_data() failed", QUIC_EV_CONN_PRSHPKT, qc);
goto leave; goto leave;
} }
@ -7557,13 +7557,13 @@ static inline int qc_build_frms(struct list *outlist, struct list *inlist,
if (cf->stream.dup) { if (cf->stream.dup) {
struct eb64_node *node = NULL; struct eb64_node *node = NULL;
struct qc_stream_desc *stream_desc = NULL; struct qc_stream_desc *stream_desc = NULL;
struct qf_stream *strm = &cf->stream; struct qf_stream *strm_frm = &cf->stream;
/* As this frame has been already lost, ensure the stream is always /* As this frame has been already lost, ensure the stream is always
* available or the range of this frame is not consumed before * available or the range of this frame is not consumed before
* resending it. * resending it.
*/ */
node = eb64_lookup(&qc->streams_by_id, strm->id); node = eb64_lookup(&qc->streams_by_id, strm_frm->id);
if (!node) { if (!node) {
TRACE_DEVEL("released stream", QUIC_EV_CONN_PRSAFRM, qc, cf); TRACE_DEVEL("released stream", QUIC_EV_CONN_PRSAFRM, qc, cf);
qc_frm_free(&cf); qc_frm_free(&cf);
@ -7571,14 +7571,14 @@ static inline int qc_build_frms(struct list *outlist, struct list *inlist,
} }
stream_desc = eb64_entry(node, struct qc_stream_desc, by_id); stream_desc = eb64_entry(node, struct qc_stream_desc, by_id);
if (strm->offset.key + strm->len <= stream_desc->ack_offset) { if (strm_frm->offset.key + strm_frm->len <= stream_desc->ack_offset) {
TRACE_DEVEL("ignored frame frame in already acked range", TRACE_DEVEL("ignored frame frame in already acked range",
QUIC_EV_CONN_PRSAFRM, qc, cf); QUIC_EV_CONN_PRSAFRM, qc, cf);
qc_frm_free(&cf); qc_frm_free(&cf);
continue; continue;
} }
else if (strm->offset.key < stream_desc->ack_offset) { else if (strm_frm->offset.key < stream_desc->ack_offset) {
uint64_t diff = stream_desc->ack_offset - strm->offset.key; uint64_t diff = stream_desc->ack_offset - strm_frm->offset.key;
qc_stream_frm_mv_fwd(cf, diff); qc_stream_frm_mv_fwd(cf, diff);
TRACE_DEVEL("updated partially acked frame", TRACE_DEVEL("updated partially acked frame",

View File

@ -109,111 +109,111 @@ void chunk_frm_appendf(struct buffer *buf, const struct quic_frame *frm)
switch (frm->type) { switch (frm->type) {
case QUIC_FT_CRYPTO: case QUIC_FT_CRYPTO:
{ {
const struct qf_crypto *cf = &frm->crypto; const struct qf_crypto *crypto_frm = &frm->crypto;
chunk_appendf(buf, " cfoff=%llu cflen=%llu", chunk_appendf(buf, " cfoff=%llu cflen=%llu",
(ull)cf->offset, (ull)cf->len); (ull)crypto_frm->offset, (ull)crypto_frm->len);
break; break;
} }
case QUIC_FT_RESET_STREAM: case QUIC_FT_RESET_STREAM:
{ {
const struct qf_reset_stream *rs = &frm->reset_stream; const struct qf_reset_stream *rs_frm = &frm->reset_stream;
chunk_appendf(buf, " id=%llu app_error_code=%llu final_size=%llu", chunk_appendf(buf, " id=%llu app_error_code=%llu final_size=%llu",
(ull)rs->id, (ull)rs->app_error_code, (ull)rs->final_size); (ull)rs_frm->id, (ull)rs_frm->app_error_code, (ull)rs_frm->final_size);
break; break;
} }
case QUIC_FT_STOP_SENDING: case QUIC_FT_STOP_SENDING:
{ {
const struct qf_stop_sending *s = &frm->stop_sending; const struct qf_stop_sending *ss_frm = &frm->stop_sending;
chunk_appendf(&trace_buf, " id=%llu app_error_code=%llu", chunk_appendf(&trace_buf, " id=%llu app_error_code=%llu",
(ull)s->id, (ull)s->app_error_code); (ull)ss_frm->id, (ull)ss_frm->app_error_code);
break; break;
} }
case QUIC_FT_STREAM_8 ... QUIC_FT_STREAM_F: case QUIC_FT_STREAM_8 ... QUIC_FT_STREAM_F:
{ {
const struct qf_stream *s = &frm->stream; const struct qf_stream *strm_frm = &frm->stream;
chunk_appendf(&trace_buf, " uni=%d fin=%d id=%llu off=%llu len=%llu", chunk_appendf(&trace_buf, " uni=%d fin=%d id=%llu off=%llu len=%llu",
!!(s->id & QUIC_STREAM_FRAME_ID_DIR_BIT), !!(strm_frm->id & QUIC_STREAM_FRAME_ID_DIR_BIT),
!!(frm->type & QUIC_STREAM_FRAME_TYPE_FIN_BIT), !!(frm->type & QUIC_STREAM_FRAME_TYPE_FIN_BIT),
(ull)s->id, (ull)s->offset.key, (ull)s->len); (ull)strm_frm->id, (ull)strm_frm->offset.key, (ull)strm_frm->len);
break; break;
} }
case QUIC_FT_MAX_DATA: case QUIC_FT_MAX_DATA:
{ {
const struct qf_max_data *s = &frm->max_data; const struct qf_max_data *md_frm = &frm->max_data;
chunk_appendf(&trace_buf, " max_data=%llu", (ull)s->max_data); chunk_appendf(&trace_buf, " max_data=%llu", (ull)md_frm->max_data);
break; break;
} }
case QUIC_FT_MAX_STREAM_DATA: case QUIC_FT_MAX_STREAM_DATA:
{ {
const struct qf_max_stream_data *s = &frm->max_stream_data; const struct qf_max_stream_data *msd_frm = &frm->max_stream_data;
chunk_appendf(&trace_buf, " id=%llu max_stream_data=%llu", chunk_appendf(&trace_buf, " id=%llu max_stream_data=%llu",
(ull)s->id, (ull)s->max_stream_data); (ull)msd_frm->id, (ull)msd_frm->max_stream_data);
break; break;
} }
case QUIC_FT_MAX_STREAMS_BIDI: case QUIC_FT_MAX_STREAMS_BIDI:
{ {
const struct qf_max_streams *s = &frm->max_streams_bidi; const struct qf_max_streams *ms_frm = &frm->max_streams_bidi;
chunk_appendf(&trace_buf, " max_streams=%llu", (ull)s->max_streams); chunk_appendf(&trace_buf, " max_streams=%llu", (ull)ms_frm->max_streams);
break; break;
} }
case QUIC_FT_MAX_STREAMS_UNI: case QUIC_FT_MAX_STREAMS_UNI:
{ {
const struct qf_max_streams *s = &frm->max_streams_uni; const struct qf_max_streams *ms_frm = &frm->max_streams_uni;
chunk_appendf(&trace_buf, " max_streams=%llu", (ull)s->max_streams); chunk_appendf(&trace_buf, " max_streams=%llu", (ull)ms_frm->max_streams);
break; break;
} }
case QUIC_FT_DATA_BLOCKED: case QUIC_FT_DATA_BLOCKED:
{ {
const struct qf_data_blocked *s = &frm->data_blocked; const struct qf_data_blocked *db_frm = &frm->data_blocked;
chunk_appendf(&trace_buf, " limit=%llu", (ull)s->limit); chunk_appendf(&trace_buf, " limit=%llu", (ull)db_frm->limit);
break; break;
} }
case QUIC_FT_STREAM_DATA_BLOCKED: case QUIC_FT_STREAM_DATA_BLOCKED:
{ {
const struct qf_stream_data_blocked *s = &frm->stream_data_blocked; const struct qf_stream_data_blocked *sdb_frm = &frm->stream_data_blocked;
chunk_appendf(&trace_buf, " id=%llu limit=%llu", chunk_appendf(&trace_buf, " id=%llu limit=%llu",
(ull)s->id, (ull)s->limit); (ull)sdb_frm->id, (ull)sdb_frm->limit);
break; break;
} }
case QUIC_FT_STREAMS_BLOCKED_BIDI: case QUIC_FT_STREAMS_BLOCKED_BIDI:
{ {
const struct qf_streams_blocked *s = &frm->streams_blocked_bidi; const struct qf_streams_blocked *sb_frm = &frm->streams_blocked_bidi;
chunk_appendf(&trace_buf, " limit=%llu", (ull)s->limit); chunk_appendf(&trace_buf, " limit=%llu", (ull)sb_frm->limit);
break; break;
} }
case QUIC_FT_STREAMS_BLOCKED_UNI: case QUIC_FT_STREAMS_BLOCKED_UNI:
{ {
const struct qf_streams_blocked *s = &frm->streams_blocked_uni; const struct qf_streams_blocked *sb_frm = &frm->streams_blocked_uni;
chunk_appendf(&trace_buf, " limit=%llu", (ull)s->limit); chunk_appendf(&trace_buf, " limit=%llu", (ull)sb_frm->limit);
break; break;
} }
case QUIC_FT_RETIRE_CONNECTION_ID: case QUIC_FT_RETIRE_CONNECTION_ID:
{ {
const struct qf_retire_connection_id *rci = &frm->retire_connection_id; const struct qf_retire_connection_id *rcid_frm = &frm->retire_connection_id;
chunk_appendf(&trace_buf, " seq_num=%llu", (ull)rci->seq_num); chunk_appendf(&trace_buf, " seq_num=%llu", (ull)rcid_frm->seq_num);
break; break;
} }
case QUIC_FT_CONNECTION_CLOSE: case QUIC_FT_CONNECTION_CLOSE:
{ {
const struct qf_connection_close *cc = &frm->connection_close; const struct qf_connection_close *cc_frm = &frm->connection_close;
size_t plen = QUIC_MIN((size_t)cc->reason_phrase_len, sizeof cc->reason_phrase); size_t plen = QUIC_MIN((size_t)cc_frm->reason_phrase_len, sizeof cc_frm->reason_phrase);
chunk_appendf(&trace_buf, chunk_appendf(&trace_buf,
" error_code=%llu frame_type=%llu reason_phrase_len=%llu", " error_code=%llu frame_type=%llu reason_phrase_len=%llu",
(ull)cc->error_code, (ull)cc->frame_type, (ull)cc_frm->error_code, (ull)cc_frm->frame_type,
(ull)cc->reason_phrase_len); (ull)cc_frm->reason_phrase_len);
if (plen) if (plen)
chunk_cc_phrase_appendf(&trace_buf, cc->reason_phrase, plen); chunk_cc_phrase_appendf(&trace_buf, cc_frm->reason_phrase, plen);
break; break;
} }
case QUIC_FT_CONNECTION_CLOSE_APP: case QUIC_FT_CONNECTION_CLOSE_APP:
{ {
const struct qf_connection_close_app *cc = &frm->connection_close_app; const struct qf_connection_close_app *cc_frm = &frm->connection_close_app;
size_t plen = QUIC_MIN((size_t)cc->reason_phrase_len, sizeof cc->reason_phrase); size_t plen = QUIC_MIN((size_t)cc_frm->reason_phrase_len, sizeof cc_frm->reason_phrase);
chunk_appendf(&trace_buf, chunk_appendf(&trace_buf,
" error_code=%llu reason_phrase_len=%llu", " error_code=%llu reason_phrase_len=%llu",
(ull)cc->error_code, (ull)cc->reason_phrase_len); (ull)cc_frm->error_code, (ull)cc_frm->reason_phrase_len);
if (plen) if (plen)
chunk_cc_phrase_appendf(&trace_buf, cc->reason_phrase, plen); chunk_cc_phrase_appendf(&trace_buf, cc_frm->reason_phrase, plen);
break; break;
} }
} }
@ -225,13 +225,13 @@ void chunk_frm_appendf(struct buffer *buf, const struct quic_frame *frm)
static int quic_build_padding_frame(unsigned char **buf, const unsigned char *end, static int quic_build_padding_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_padding *padding = &frm->padding; struct qf_padding *padding_frm = &frm->padding;
if (end - *buf < padding->len - 1) if (end - *buf < padding_frm->len - 1)
return 0; return 0;
memset(*buf, 0, padding->len - 1); memset(*buf, 0, padding_frm->len - 1);
*buf += padding->len - 1; *buf += padding_frm->len - 1;
return 1; return 1;
} }
@ -243,13 +243,13 @@ static int quic_parse_padding_frame(struct quic_frame *frm, struct quic_conn *qc
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
const unsigned char *beg; const unsigned char *beg;
struct qf_padding *padding = &frm->padding; struct qf_padding *padding_frm = &frm->padding;
beg = *buf; beg = *buf;
padding->len = 1; padding_frm->len = 1;
while (*buf < end && !**buf) while (*buf < end && !**buf)
(*buf)++; (*buf)++;
padding->len += *buf - beg; padding_frm->len += *buf - beg;
return 1; return 1;
} }
@ -280,17 +280,17 @@ static int quic_parse_ping_frame(struct quic_frame *frm, struct quic_conn *qc,
static int quic_build_ack_frame(unsigned char **buf, const unsigned char *end, static int quic_build_ack_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *qc) struct quic_frame *frm, struct quic_conn *qc)
{ {
struct qf_tx_ack *tx_ack = &frm->tx_ack; struct qf_tx_ack *ack_frm = &frm->tx_ack;
struct eb64_node *ar, *prev_ar; struct eb64_node *ar, *prev_ar;
struct quic_arng_node *ar_node, *prev_ar_node; struct quic_arng_node *ar_node, *prev_ar_node;
ar = eb64_last(&tx_ack->arngs->root); ar = eb64_last(&ack_frm->arngs->root);
ar_node = eb64_entry(ar, struct quic_arng_node, first); ar_node = eb64_entry(ar, struct quic_arng_node, first);
TRACE_PROTO("TX ack range", QUIC_EV_CONN_PRSAFRM, TRACE_PROTO("TX ack range", QUIC_EV_CONN_PRSAFRM,
qc,, &ar_node->last, &ar_node->first.key); qc,, &ar_node->last, &ar_node->first.key);
if (!quic_enc_int(buf, end, ar_node->last) || if (!quic_enc_int(buf, end, ar_node->last) ||
!quic_enc_int(buf, end, tx_ack->ack_delay) || !quic_enc_int(buf, end, ack_frm->ack_delay) ||
!quic_enc_int(buf, end, tx_ack->arngs->sz - 1) || !quic_enc_int(buf, end, ack_frm->arngs->sz - 1) ||
!quic_enc_int(buf, end, ar_node->last - ar_node->first.key)) !quic_enc_int(buf, end, ar_node->last - ar_node->first.key))
return 0; return 0;
@ -316,21 +316,21 @@ static int quic_parse_ack_frame_header(struct quic_frame *frm, struct quic_conn
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
int ret; int ret;
struct qf_ack *ack = &frm->ack; struct qf_ack *ack_frm = &frm->ack;
ret = quic_dec_int(&ack->largest_ack, buf, end); ret = quic_dec_int(&ack_frm->largest_ack, buf, end);
if (!ret) if (!ret)
return 0; return 0;
ret = quic_dec_int(&ack->ack_delay, buf, end); ret = quic_dec_int(&ack_frm->ack_delay, buf, end);
if (!ret) if (!ret)
return 0; return 0;
ret = quic_dec_int(&ack->ack_range_num, buf, end); ret = quic_dec_int(&ack_frm->ack_range_num, buf, end);
if (!ret) if (!ret)
return 0; return 0;
ret = quic_dec_int(&ack->first_ack_range, buf, end); ret = quic_dec_int(&ack_frm->first_ack_range, buf, end);
if (!ret) if (!ret)
return 0; return 0;
@ -343,12 +343,12 @@ static int quic_parse_ack_frame_header(struct quic_frame *frm, struct quic_conn
static int quic_build_ack_ecn_frame(unsigned char **buf, const unsigned char *end, static int quic_build_ack_ecn_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_ack *ack = &frm->ack; struct qf_ack *ack_frm = &frm->ack;
return quic_enc_int(buf, end, ack->largest_ack) && return quic_enc_int(buf, end, ack_frm->largest_ack) &&
quic_enc_int(buf, end, ack->ack_delay) && quic_enc_int(buf, end, ack_frm->ack_delay) &&
quic_enc_int(buf, end, ack->first_ack_range) && quic_enc_int(buf, end, ack_frm->first_ack_range) &&
quic_enc_int(buf, end, ack->ack_range_num); quic_enc_int(buf, end, ack_frm->ack_range_num);
} }
/* Parse an ACK_ECN frame from <buf> buffer with <end> as end into <frm> frame. /* Parse an ACK_ECN frame from <buf> buffer with <end> as end into <frm> frame.
@ -357,12 +357,12 @@ static int quic_build_ack_ecn_frame(unsigned char **buf, const unsigned char *en
static int quic_parse_ack_ecn_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_ack_ecn_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_ack *ack = &frm->ack; struct qf_ack *ack_frm = &frm->ack;
return quic_dec_int(&ack->largest_ack, buf, end) && return quic_dec_int(&ack_frm->largest_ack, buf, end) &&
quic_dec_int(&ack->ack_delay, buf, end) && quic_dec_int(&ack_frm->ack_delay, buf, end) &&
quic_dec_int(&ack->first_ack_range, buf, end) && quic_dec_int(&ack_frm->first_ack_range, buf, end) &&
quic_dec_int(&ack->ack_range_num, buf, end); quic_dec_int(&ack_frm->ack_range_num, buf, end);
} }
/* Encode a RESET_STREAM frame into <buf> buffer. /* Encode a RESET_STREAM frame into <buf> buffer.
@ -371,11 +371,11 @@ static int quic_parse_ack_ecn_frame(struct quic_frame *frm, struct quic_conn *qc
static int quic_build_reset_stream_frame(unsigned char **buf, const unsigned char *end, static int quic_build_reset_stream_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_reset_stream *reset_stream = &frm->reset_stream; struct qf_reset_stream *rs_frm = &frm->reset_stream;
return quic_enc_int(buf, end, reset_stream->id) && return quic_enc_int(buf, end, rs_frm->id) &&
quic_enc_int(buf, end, reset_stream->app_error_code) && quic_enc_int(buf, end, rs_frm->app_error_code) &&
quic_enc_int(buf, end, reset_stream->final_size); quic_enc_int(buf, end, rs_frm->final_size);
} }
/* Parse a RESET_STREAM frame from <buf> buffer with <end> as end into <frm> frame. /* Parse a RESET_STREAM frame from <buf> buffer with <end> as end into <frm> frame.
@ -384,11 +384,11 @@ static int quic_build_reset_stream_frame(unsigned char **buf, const unsigned cha
static int quic_parse_reset_stream_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_reset_stream_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_reset_stream *reset_stream = &frm->reset_stream; struct qf_reset_stream *rs_frm = &frm->reset_stream;
return quic_dec_int(&reset_stream->id, buf, end) && return quic_dec_int(&rs_frm->id, buf, end) &&
quic_dec_int(&reset_stream->app_error_code, buf, end) && quic_dec_int(&rs_frm->app_error_code, buf, end) &&
quic_dec_int(&reset_stream->final_size, buf, end); quic_dec_int(&rs_frm->final_size, buf, end);
} }
/* Encode a STOP_SENDING frame. /* Encode a STOP_SENDING frame.
@ -397,10 +397,10 @@ static int quic_parse_reset_stream_frame(struct quic_frame *frm, struct quic_con
static int quic_build_stop_sending_frame(unsigned char **buf, const unsigned char *end, static int quic_build_stop_sending_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_stop_sending *stop_sending = &frm->stop_sending; struct qf_stop_sending *ss_frm = &frm->stop_sending;
return quic_enc_int(buf, end, stop_sending->id) && return quic_enc_int(buf, end, ss_frm->id) &&
quic_enc_int(buf, end, stop_sending->app_error_code); quic_enc_int(buf, end, ss_frm->app_error_code);
} }
/* Parse a STOP_SENDING frame from <buf> buffer with <end> as end into <frm> frame. /* Parse a STOP_SENDING frame from <buf> buffer with <end> as end into <frm> frame.
@ -409,10 +409,10 @@ static int quic_build_stop_sending_frame(unsigned char **buf, const unsigned cha
static int quic_parse_stop_sending_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_stop_sending_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_stop_sending *stop_sending = &frm->stop_sending; struct qf_stop_sending *ss_frm = &frm->stop_sending;
return quic_dec_int(&stop_sending->id, buf, end) && return quic_dec_int(&ss_frm->id, buf, end) &&
quic_dec_int(&stop_sending->app_error_code, buf, end); quic_dec_int(&ss_frm->app_error_code, buf, end);
} }
/* Encode a CRYPTO frame into <buf> buffer. /* Encode a CRYPTO frame into <buf> buffer.
@ -421,16 +421,16 @@ static int quic_parse_stop_sending_frame(struct quic_frame *frm, struct quic_con
static int quic_build_crypto_frame(unsigned char **buf, const unsigned char *end, static int quic_build_crypto_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_crypto *crypto = &frm->crypto; struct qf_crypto *crypto_frm = &frm->crypto;
const struct quic_enc_level *qel = crypto->qel; const struct quic_enc_level *qel = crypto_frm->qel;
size_t offset, len; size_t offset, len;
if (!quic_enc_int(buf, end, crypto->offset) || if (!quic_enc_int(buf, end, crypto_frm->offset) ||
!quic_enc_int(buf, end, crypto->len) || end - *buf < crypto->len) !quic_enc_int(buf, end, crypto_frm->len) || end - *buf < crypto_frm->len)
return 0; return 0;
len = crypto->len; len = crypto_frm->len;
offset = crypto->offset; offset = crypto_frm->offset;
while (len) { while (len) {
int idx; int idx;
size_t to_copy; size_t to_copy;
@ -456,14 +456,14 @@ static int quic_build_crypto_frame(unsigned char **buf, const unsigned char *end
static int quic_parse_crypto_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_crypto_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_crypto *crypto = &frm->crypto; struct qf_crypto *crypto_frm = &frm->crypto;
if (!quic_dec_int(&crypto->offset, buf, end) || if (!quic_dec_int(&crypto_frm->offset, buf, end) ||
!quic_dec_int(&crypto->len, buf, end) || end - *buf < crypto->len) !quic_dec_int(&crypto_frm->len, buf, end) || end - *buf < crypto_frm->len)
return 0; return 0;
crypto->data = *buf; crypto_frm->data = *buf;
*buf += crypto->len; *buf += crypto_frm->len;
return 1; return 1;
} }
@ -474,12 +474,12 @@ static int quic_parse_crypto_frame(struct quic_frame *frm, struct quic_conn *qc,
static int quic_build_new_token_frame(unsigned char **buf, const unsigned char *end, static int quic_build_new_token_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_new_token *new_token = &frm->new_token; struct qf_new_token *new_token_frm = &frm->new_token;
if (!quic_enc_int(buf, end, new_token->len) || end - *buf < new_token->len) if (!quic_enc_int(buf, end, new_token_frm->len) || end - *buf < new_token_frm->len)
return 0; return 0;
memcpy(*buf, new_token->data, new_token->len); memcpy(*buf, new_token_frm->data, new_token_frm->len);
return 1; return 1;
} }
@ -490,13 +490,13 @@ static int quic_build_new_token_frame(unsigned char **buf, const unsigned char *
static int quic_parse_new_token_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_new_token_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_new_token *new_token = &frm->new_token; struct qf_new_token *new_token_frm = &frm->new_token;
if (!quic_dec_int(&new_token->len, buf, end) || end - *buf < new_token->len) if (!quic_dec_int(&new_token_frm->len, buf, end) || end - *buf < new_token_frm->len)
return 0; return 0;
new_token->data = *buf; new_token_frm->data = *buf;
*buf += new_token->len; *buf += new_token_frm->len;
return 1; return 1;
} }
@ -507,32 +507,32 @@ static int quic_parse_new_token_frame(struct quic_frame *frm, struct quic_conn *
static int quic_build_stream_frame(unsigned char **buf, const unsigned char *end, static int quic_build_stream_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_stream *stream = &frm->stream; struct qf_stream *strm_frm = &frm->stream;
const unsigned char *wrap; const unsigned char *wrap;
/* Caller must set OFF bit if and only if a non-null offset is used. */ /* Caller must set OFF bit if and only if a non-null offset is used. */
BUG_ON(!!(frm->type & QUIC_STREAM_FRAME_TYPE_OFF_BIT) != BUG_ON(!!(frm->type & QUIC_STREAM_FRAME_TYPE_OFF_BIT) !=
!!stream->offset.key); !!strm_frm->offset.key);
if (!quic_enc_int(buf, end, stream->id) || if (!quic_enc_int(buf, end, strm_frm->id) ||
((frm->type & QUIC_STREAM_FRAME_TYPE_OFF_BIT) && !quic_enc_int(buf, end, stream->offset.key)) || ((frm->type & QUIC_STREAM_FRAME_TYPE_OFF_BIT) && !quic_enc_int(buf, end, strm_frm->offset.key)) ||
((frm->type & QUIC_STREAM_FRAME_TYPE_LEN_BIT) && ((frm->type & QUIC_STREAM_FRAME_TYPE_LEN_BIT) &&
(!quic_enc_int(buf, end, stream->len) || end - *buf < stream->len))) (!quic_enc_int(buf, end, strm_frm->len) || end - *buf < strm_frm->len)))
return 0; return 0;
wrap = (const unsigned char *)b_wrap(stream->buf); wrap = (const unsigned char *)b_wrap(strm_frm->buf);
if (stream->data + stream->len > wrap) { if (strm_frm->data + strm_frm->len > wrap) {
size_t to_copy = wrap - stream->data; size_t to_copy = wrap - strm_frm->data;
memcpy(*buf, stream->data, to_copy); memcpy(*buf, strm_frm->data, to_copy);
*buf += to_copy; *buf += to_copy;
to_copy = stream->len - to_copy; to_copy = strm_frm->len - to_copy;
memcpy(*buf, b_orig(stream->buf), to_copy); memcpy(*buf, b_orig(strm_frm->buf), to_copy);
*buf += to_copy; *buf += to_copy;
} }
else { else {
memcpy(*buf, stream->data, stream->len); memcpy(*buf, strm_frm->data, strm_frm->len);
*buf += stream->len; *buf += strm_frm->len;
} }
return 1; return 1;
@ -544,27 +544,27 @@ static int quic_build_stream_frame(unsigned char **buf, const unsigned char *end
static int quic_parse_stream_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_stream_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_stream *stream = &frm->stream; struct qf_stream *strm_frm = &frm->stream;
if (!quic_dec_int(&stream->id, buf, end)) if (!quic_dec_int(&strm_frm->id, buf, end))
return 0; return 0;
/* Offset parsing */ /* Offset parsing */
if (!(frm->type & QUIC_STREAM_FRAME_TYPE_OFF_BIT)) { if (!(frm->type & QUIC_STREAM_FRAME_TYPE_OFF_BIT)) {
stream->offset.key = 0; strm_frm->offset.key = 0;
} }
else if (!quic_dec_int((uint64_t *)&stream->offset.key, buf, end)) else if (!quic_dec_int((uint64_t *)&strm_frm->offset.key, buf, end))
return 0; return 0;
/* Length parsing */ /* Length parsing */
if (!(frm->type & QUIC_STREAM_FRAME_TYPE_LEN_BIT)) { if (!(frm->type & QUIC_STREAM_FRAME_TYPE_LEN_BIT)) {
stream->len = end - *buf; strm_frm->len = end - *buf;
} }
else if (!quic_dec_int(&stream->len, buf, end) || end - *buf < stream->len) else if (!quic_dec_int(&strm_frm->len, buf, end) || end - *buf < strm_frm->len)
return 0; return 0;
stream->data = *buf; strm_frm->data = *buf;
*buf += stream->len; *buf += strm_frm->len;
return 1; return 1;
} }
@ -575,9 +575,9 @@ static int quic_parse_stream_frame(struct quic_frame *frm, struct quic_conn *qc,
static int quic_build_max_data_frame(unsigned char **buf, const unsigned char *end, static int quic_build_max_data_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_max_data *max_data = &frm->max_data; struct qf_max_data *md_frm = &frm->max_data;
return quic_enc_int(buf, end, max_data->max_data); return quic_enc_int(buf, end, md_frm->max_data);
} }
/* Parse a MAX_DATA frame from <buf> buffer with <end> as end into <frm> frame. /* Parse a MAX_DATA frame from <buf> buffer with <end> as end into <frm> frame.
@ -586,9 +586,9 @@ static int quic_build_max_data_frame(unsigned char **buf, const unsigned char *e
static int quic_parse_max_data_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_max_data_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_max_data *max_data = &frm->max_data; struct qf_max_data *md_frm = &frm->max_data;
return quic_dec_int(&max_data->max_data, buf, end); return quic_dec_int(&md_frm->max_data, buf, end);
} }
/* Encode a MAX_STREAM_DATA frame into <buf> buffer. /* Encode a MAX_STREAM_DATA frame into <buf> buffer.
@ -597,10 +597,10 @@ static int quic_parse_max_data_frame(struct quic_frame *frm, struct quic_conn *q
static int quic_build_max_stream_data_frame(unsigned char **buf, const unsigned char *end, static int quic_build_max_stream_data_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_max_stream_data *max_stream_data = &frm->max_stream_data; struct qf_max_stream_data *msd_frm = &frm->max_stream_data;
return quic_enc_int(buf, end, max_stream_data->id) && return quic_enc_int(buf, end, msd_frm->id) &&
quic_enc_int(buf, end, max_stream_data->max_stream_data); quic_enc_int(buf, end, msd_frm->max_stream_data);
} }
/* Parse a MAX_STREAM_DATA frame from <buf> buffer with <end> as end into <frm> frame. /* Parse a MAX_STREAM_DATA frame from <buf> buffer with <end> as end into <frm> frame.
@ -609,10 +609,10 @@ static int quic_build_max_stream_data_frame(unsigned char **buf, const unsigned
static int quic_parse_max_stream_data_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_max_stream_data_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_max_stream_data *max_stream_data = &frm->max_stream_data; struct qf_max_stream_data *msd_frm = &frm->max_stream_data;
return quic_dec_int(&max_stream_data->id, buf, end) && return quic_dec_int(&msd_frm->id, buf, end) &&
quic_dec_int(&max_stream_data->max_stream_data, buf, end); quic_dec_int(&msd_frm->max_stream_data, buf, end);
} }
/* Encode a MAX_STREAMS frame for bidirectional streams into <buf> buffer. /* Encode a MAX_STREAMS frame for bidirectional streams into <buf> buffer.
@ -621,9 +621,9 @@ static int quic_parse_max_stream_data_frame(struct quic_frame *frm, struct quic_
static int quic_build_max_streams_bidi_frame(unsigned char **buf, const unsigned char *end, static int quic_build_max_streams_bidi_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_max_streams *max_streams_bidi = &frm->max_streams_bidi; struct qf_max_streams *ms_frm = &frm->max_streams_bidi;
return quic_enc_int(buf, end, max_streams_bidi->max_streams); return quic_enc_int(buf, end, ms_frm->max_streams);
} }
/* Parse a MAX_STREAMS frame for bidirectional streams from <buf> buffer with <end> /* Parse a MAX_STREAMS frame for bidirectional streams from <buf> buffer with <end>
@ -633,9 +633,9 @@ static int quic_build_max_streams_bidi_frame(unsigned char **buf, const unsigned
static int quic_parse_max_streams_bidi_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_max_streams_bidi_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_max_streams *max_streams_bidi = &frm->max_streams_bidi; struct qf_max_streams *ms_frm = &frm->max_streams_bidi;
return quic_dec_int(&max_streams_bidi->max_streams, buf, end); return quic_dec_int(&ms_frm->max_streams, buf, end);
} }
/* Encode a MAX_STREAMS frame for unidirectional streams into <buf> buffer. /* Encode a MAX_STREAMS frame for unidirectional streams into <buf> buffer.
@ -644,9 +644,9 @@ static int quic_parse_max_streams_bidi_frame(struct quic_frame *frm, struct quic
static int quic_build_max_streams_uni_frame(unsigned char **buf, const unsigned char *end, static int quic_build_max_streams_uni_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_max_streams *max_streams_uni = &frm->max_streams_uni; struct qf_max_streams *ms_frm = &frm->max_streams_uni;
return quic_enc_int(buf, end, max_streams_uni->max_streams); return quic_enc_int(buf, end, ms_frm->max_streams);
} }
/* Parse a MAX_STREAMS frame for undirectional streams from <buf> buffer with <end> /* Parse a MAX_STREAMS frame for undirectional streams from <buf> buffer with <end>
@ -656,9 +656,9 @@ static int quic_build_max_streams_uni_frame(unsigned char **buf, const unsigned
static int quic_parse_max_streams_uni_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_max_streams_uni_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_max_streams *max_streams_uni = &frm->max_streams_uni; struct qf_max_streams *ms_frm = &frm->max_streams_uni;
return quic_dec_int(&max_streams_uni->max_streams, buf, end); return quic_dec_int(&ms_frm->max_streams, buf, end);
} }
/* Encode a DATA_BLOCKED frame into <buf> buffer. /* Encode a DATA_BLOCKED frame into <buf> buffer.
@ -667,9 +667,9 @@ static int quic_parse_max_streams_uni_frame(struct quic_frame *frm, struct quic_
static int quic_build_data_blocked_frame(unsigned char **buf, const unsigned char *end, static int quic_build_data_blocked_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_data_blocked *data_blocked = &frm->data_blocked; struct qf_data_blocked *db_frm = &frm->data_blocked;
return quic_enc_int(buf, end, data_blocked->limit); return quic_enc_int(buf, end, db_frm->limit);
} }
/* Parse a DATA_BLOCKED frame from <buf> buffer with <end> as end into <frm> frame. /* Parse a DATA_BLOCKED frame from <buf> buffer with <end> as end into <frm> frame.
@ -678,9 +678,9 @@ static int quic_build_data_blocked_frame(unsigned char **buf, const unsigned cha
static int quic_parse_data_blocked_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_data_blocked_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_data_blocked *data_blocked = &frm->data_blocked; struct qf_data_blocked *db_frm = &frm->data_blocked;
return quic_dec_int(&data_blocked->limit, buf, end); return quic_dec_int(&db_frm->limit, buf, end);
} }
/* Encode a STREAM_DATA_BLOCKED into <buf> buffer. /* Encode a STREAM_DATA_BLOCKED into <buf> buffer.
@ -689,10 +689,10 @@ static int quic_parse_data_blocked_frame(struct quic_frame *frm, struct quic_con
static int quic_build_stream_data_blocked_frame(unsigned char **buf, const unsigned char *end, static int quic_build_stream_data_blocked_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_stream_data_blocked *stream_data_blocked = &frm->stream_data_blocked; struct qf_stream_data_blocked *sdb_frm = &frm->stream_data_blocked;
return quic_enc_int(buf, end, stream_data_blocked->id) && return quic_enc_int(buf, end, sdb_frm->id) &&
quic_enc_int(buf, end, stream_data_blocked->limit); quic_enc_int(buf, end, sdb_frm->limit);
} }
/* Parse a STREAM_DATA_BLOCKED frame from <buf> buffer with <end> as end into <frm> frame. /* Parse a STREAM_DATA_BLOCKED frame from <buf> buffer with <end> as end into <frm> frame.
@ -701,10 +701,10 @@ static int quic_build_stream_data_blocked_frame(unsigned char **buf, const unsig
static int quic_parse_stream_data_blocked_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_stream_data_blocked_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_stream_data_blocked *stream_data_blocked = &frm->stream_data_blocked; struct qf_stream_data_blocked *sdb_frm = &frm->stream_data_blocked;
return quic_dec_int(&stream_data_blocked->id, buf, end) && return quic_dec_int(&sdb_frm->id, buf, end) &&
quic_dec_int(&stream_data_blocked->limit, buf, end); quic_dec_int(&sdb_frm->limit, buf, end);
} }
/* Encode a STREAMS_BLOCKED frame for bidirectional streams into <buf> buffer. /* Encode a STREAMS_BLOCKED frame for bidirectional streams into <buf> buffer.
@ -713,9 +713,9 @@ static int quic_parse_stream_data_blocked_frame(struct quic_frame *frm, struct q
static int quic_build_streams_blocked_bidi_frame(unsigned char **buf, const unsigned char *end, static int quic_build_streams_blocked_bidi_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_streams_blocked *streams_blocked_bidi = &frm->streams_blocked_bidi; struct qf_streams_blocked *sb_frm = &frm->streams_blocked_bidi;
return quic_enc_int(buf, end, streams_blocked_bidi->limit); return quic_enc_int(buf, end, sb_frm->limit);
} }
/* Parse a STREAMS_BLOCKED frame for bidirectional streams from <buf> buffer with <end> /* Parse a STREAMS_BLOCKED frame for bidirectional streams from <buf> buffer with <end>
@ -725,9 +725,9 @@ static int quic_build_streams_blocked_bidi_frame(unsigned char **buf, const unsi
static int quic_parse_streams_blocked_bidi_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_streams_blocked_bidi_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_streams_blocked *streams_blocked_bidi = &frm->streams_blocked_bidi; struct qf_streams_blocked *sb_frm = &frm->streams_blocked_bidi;
return quic_dec_int(&streams_blocked_bidi->limit, buf, end); return quic_dec_int(&sb_frm->limit, buf, end);
} }
/* Encode a STREAMS_BLOCKED frame for unidirectional streams into <buf> buffer. /* Encode a STREAMS_BLOCKED frame for unidirectional streams into <buf> buffer.
@ -736,9 +736,9 @@ static int quic_parse_streams_blocked_bidi_frame(struct quic_frame *frm, struct
static int quic_build_streams_blocked_uni_frame(unsigned char **buf, const unsigned char *end, static int quic_build_streams_blocked_uni_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_streams_blocked *streams_blocked_uni = &frm->streams_blocked_uni; struct qf_streams_blocked *sb_frm = &frm->streams_blocked_uni;
return quic_enc_int(buf, end, streams_blocked_uni->limit); return quic_enc_int(buf, end, sb_frm->limit);
} }
/* Parse a STREAMS_BLOCKED frame for unidirectional streams from <buf> buffer with <end> /* Parse a STREAMS_BLOCKED frame for unidirectional streams from <buf> buffer with <end>
@ -748,9 +748,9 @@ static int quic_build_streams_blocked_uni_frame(unsigned char **buf, const unsig
static int quic_parse_streams_blocked_uni_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_streams_blocked_uni_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_streams_blocked *streams_blocked_uni = &frm->streams_blocked_uni; struct qf_streams_blocked *sb_frm = &frm->streams_blocked_uni;
return quic_dec_int(&streams_blocked_uni->limit, buf, end); return quic_dec_int(&sb_frm->limit, buf, end);
} }
/* Encode a NEW_CONNECTION_ID frame into <buf> buffer. /* Encode a NEW_CONNECTION_ID frame into <buf> buffer.
@ -759,20 +759,20 @@ static int quic_parse_streams_blocked_uni_frame(struct quic_frame *frm, struct q
static int quic_build_new_connection_id_frame(unsigned char **buf, const unsigned char *end, static int quic_build_new_connection_id_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_new_connection_id *new_cid = &frm->new_connection_id; struct qf_new_connection_id *ncid_frm = &frm->new_connection_id;
if (!quic_enc_int(buf, end, new_cid->seq_num) || if (!quic_enc_int(buf, end, ncid_frm->seq_num) ||
!quic_enc_int(buf, end, new_cid->retire_prior_to) || !quic_enc_int(buf, end, ncid_frm->retire_prior_to) ||
end - *buf < sizeof new_cid->cid.len + new_cid->cid.len + QUIC_STATELESS_RESET_TOKEN_LEN) end - *buf < sizeof ncid_frm->cid.len + ncid_frm->cid.len + QUIC_STATELESS_RESET_TOKEN_LEN)
return 0; return 0;
*(*buf)++ = new_cid->cid.len; *(*buf)++ = ncid_frm->cid.len;
if (new_cid->cid.len) { if (ncid_frm->cid.len) {
memcpy(*buf, new_cid->cid.data, new_cid->cid.len); memcpy(*buf, ncid_frm->cid.data, ncid_frm->cid.len);
*buf += new_cid->cid.len; *buf += ncid_frm->cid.len;
} }
memcpy(*buf, new_cid->stateless_reset_token, QUIC_STATELESS_RESET_TOKEN_LEN); memcpy(*buf, ncid_frm->stateless_reset_token, QUIC_STATELESS_RESET_TOKEN_LEN);
*buf += QUIC_STATELESS_RESET_TOKEN_LEN; *buf += QUIC_STATELESS_RESET_TOKEN_LEN;
return 1; return 1;
@ -784,21 +784,21 @@ static int quic_build_new_connection_id_frame(unsigned char **buf, const unsigne
static int quic_parse_new_connection_id_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_new_connection_id_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_new_connection_id *new_cid = &frm->new_connection_id; struct qf_new_connection_id *ncid_frm = &frm->new_connection_id;
if (!quic_dec_int(&new_cid->seq_num, buf, end) || if (!quic_dec_int(&ncid_frm->seq_num, buf, end) ||
!quic_dec_int(&new_cid->retire_prior_to, buf, end) || end <= *buf) !quic_dec_int(&ncid_frm->retire_prior_to, buf, end) || end <= *buf)
return 0; return 0;
new_cid->cid.len = *(*buf)++; ncid_frm->cid.len = *(*buf)++;
if (end - *buf < new_cid->cid.len + QUIC_STATELESS_RESET_TOKEN_LEN) if (end - *buf < ncid_frm->cid.len + QUIC_STATELESS_RESET_TOKEN_LEN)
return 0; return 0;
if (new_cid->cid.len) { if (ncid_frm->cid.len) {
new_cid->cid.data = *buf; ncid_frm->cid.data = *buf;
*buf += new_cid->cid.len; *buf += ncid_frm->cid.len;
} }
new_cid->stateless_reset_token = *buf; ncid_frm->stateless_reset_token = *buf;
*buf += QUIC_STATELESS_RESET_TOKEN_LEN; *buf += QUIC_STATELESS_RESET_TOKEN_LEN;
return 1; return 1;
@ -810,9 +810,9 @@ static int quic_parse_new_connection_id_frame(struct quic_frame *frm, struct qui
static int quic_build_retire_connection_id_frame(unsigned char **buf, const unsigned char *end, static int quic_build_retire_connection_id_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_retire_connection_id *retire_connection_id = &frm->retire_connection_id; struct qf_retire_connection_id *rcid_frm = &frm->retire_connection_id;
return quic_enc_int(buf, end, retire_connection_id->seq_num); return quic_enc_int(buf, end, rcid_frm->seq_num);
} }
/* Parse a RETIRE_CONNECTION_ID frame from <buf> buffer with <end> as end into <frm> frame. /* Parse a RETIRE_CONNECTION_ID frame from <buf> buffer with <end> as end into <frm> frame.
@ -821,9 +821,9 @@ static int quic_build_retire_connection_id_frame(unsigned char **buf, const unsi
static int quic_parse_retire_connection_id_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_retire_connection_id_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_retire_connection_id *retire_connection_id = &frm->retire_connection_id; struct qf_retire_connection_id *rcid_frm = &frm->retire_connection_id;
return quic_dec_int(&retire_connection_id->seq_num, buf, end); return quic_dec_int(&rcid_frm->seq_num, buf, end);
} }
/* Encode a PATH_CHALLENGE frame into <buf> buffer. /* Encode a PATH_CHALLENGE frame into <buf> buffer.
@ -832,13 +832,13 @@ static int quic_parse_retire_connection_id_frame(struct quic_frame *frm, struct
static int quic_build_path_challenge_frame(unsigned char **buf, const unsigned char *end, static int quic_build_path_challenge_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_path_challenge *path_challenge = &frm->path_challenge; struct qf_path_challenge *pc_frm = &frm->path_challenge;
if (end - *buf < sizeof path_challenge->data) if (end - *buf < sizeof pc_frm->data)
return 0; return 0;
memcpy(*buf, path_challenge->data, sizeof path_challenge->data); memcpy(*buf, pc_frm->data, sizeof pc_frm->data);
*buf += sizeof path_challenge->data; *buf += sizeof pc_frm->data;
return 1; return 1;
} }
@ -849,13 +849,13 @@ static int quic_build_path_challenge_frame(unsigned char **buf, const unsigned c
static int quic_parse_path_challenge_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_path_challenge_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_path_challenge *path_challenge = &frm->path_challenge; struct qf_path_challenge *pc_frm = &frm->path_challenge;
if (end - *buf < sizeof path_challenge->data) if (end - *buf < sizeof pc_frm->data)
return 0; return 0;
memcpy(path_challenge->data, *buf, sizeof path_challenge->data); memcpy(pc_frm->data, *buf, sizeof pc_frm->data);
*buf += sizeof path_challenge->data; *buf += sizeof pc_frm->data;
return 1; return 1;
} }
@ -867,13 +867,13 @@ static int quic_parse_path_challenge_frame(struct quic_frame *frm, struct quic_c
static int quic_build_path_response_frame(unsigned char **buf, const unsigned char *end, static int quic_build_path_response_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_path_challenge_response *path_challenge_response = &frm->path_challenge_response; struct qf_path_challenge_response *pcr_frm = &frm->path_challenge_response;
if (end - *buf < sizeof path_challenge_response->data) if (end - *buf < sizeof pcr_frm->data)
return 0; return 0;
memcpy(*buf, path_challenge_response->data, sizeof path_challenge_response->data); memcpy(*buf, pcr_frm->data, sizeof pcr_frm->data);
*buf += sizeof path_challenge_response->data; *buf += sizeof pcr_frm->data;
return 1; return 1;
} }
@ -884,13 +884,13 @@ static int quic_build_path_response_frame(unsigned char **buf, const unsigned ch
static int quic_parse_path_response_frame(struct quic_frame *frm, struct quic_conn *qc, static int quic_parse_path_response_frame(struct quic_frame *frm, struct quic_conn *qc,
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
struct qf_path_challenge_response *path_challenge_response = &frm->path_challenge_response; struct qf_path_challenge_response *pcr_frm = &frm->path_challenge_response;
if (end - *buf < sizeof path_challenge_response->data) if (end - *buf < sizeof pcr_frm->data)
return 0; return 0;
memcpy(path_challenge_response->data, *buf, sizeof path_challenge_response->data); memcpy(pcr_frm->data, *buf, sizeof pcr_frm->data);
*buf += sizeof path_challenge_response->data; *buf += sizeof pcr_frm->data;
return 1; return 1;
} }
@ -903,16 +903,16 @@ static int quic_parse_path_response_frame(struct quic_frame *frm, struct quic_co
static int quic_build_connection_close_frame(unsigned char **buf, const unsigned char *end, static int quic_build_connection_close_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_connection_close *cc = &frm->connection_close; struct qf_connection_close *cc_frm = &frm->connection_close;
if (!quic_enc_int(buf, end, cc->error_code) || if (!quic_enc_int(buf, end, cc_frm->error_code) ||
!quic_enc_int(buf, end, cc->frame_type) || !quic_enc_int(buf, end, cc_frm->frame_type) ||
!quic_enc_int(buf, end, cc->reason_phrase_len) || !quic_enc_int(buf, end, cc_frm->reason_phrase_len) ||
end - *buf < cc->reason_phrase_len) end - *buf < cc_frm->reason_phrase_len)
return 0; return 0;
memcpy(*buf, cc->reason_phrase, cc->reason_phrase_len); memcpy(*buf, cc_frm->reason_phrase, cc_frm->reason_phrase_len);
*buf += cc->reason_phrase_len; *buf += cc_frm->reason_phrase_len;
return 1; return 1;
} }
@ -926,17 +926,17 @@ static int quic_parse_connection_close_frame(struct quic_frame *frm, struct quic
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
size_t plen; size_t plen;
struct qf_connection_close *cc = &frm->connection_close; struct qf_connection_close *cc_frm = &frm->connection_close;
if (!quic_dec_int(&cc->error_code, buf, end) || if (!quic_dec_int(&cc_frm->error_code, buf, end) ||
!quic_dec_int(&cc->frame_type, buf, end) || !quic_dec_int(&cc_frm->frame_type, buf, end) ||
!quic_dec_int(&cc->reason_phrase_len, buf, end) || !quic_dec_int(&cc_frm->reason_phrase_len, buf, end) ||
end - *buf < cc->reason_phrase_len) end - *buf < cc_frm->reason_phrase_len)
return 0; return 0;
plen = QUIC_MIN((size_t)cc->reason_phrase_len, sizeof cc->reason_phrase); plen = QUIC_MIN((size_t)cc_frm->reason_phrase_len, sizeof cc_frm->reason_phrase);
memcpy(cc->reason_phrase, *buf, plen); memcpy(cc_frm->reason_phrase, *buf, plen);
*buf += cc->reason_phrase_len; *buf += cc_frm->reason_phrase_len;
return 1; return 1;
} }
@ -949,15 +949,15 @@ static int quic_parse_connection_close_frame(struct quic_frame *frm, struct quic
static int quic_build_connection_close_app_frame(unsigned char **buf, const unsigned char *end, static int quic_build_connection_close_app_frame(unsigned char **buf, const unsigned char *end,
struct quic_frame *frm, struct quic_conn *conn) struct quic_frame *frm, struct quic_conn *conn)
{ {
struct qf_connection_close_app *cc = &frm->connection_close_app; struct qf_connection_close_app *cc_frm = &frm->connection_close_app;
if (!quic_enc_int(buf, end, cc->error_code) || if (!quic_enc_int(buf, end, cc_frm->error_code) ||
!quic_enc_int(buf, end, cc->reason_phrase_len) || !quic_enc_int(buf, end, cc_frm->reason_phrase_len) ||
end - *buf < cc->reason_phrase_len) end - *buf < cc_frm->reason_phrase_len)
return 0; return 0;
memcpy(*buf, cc->reason_phrase, cc->reason_phrase_len); memcpy(*buf, cc_frm->reason_phrase, cc_frm->reason_phrase_len);
*buf += cc->reason_phrase_len; *buf += cc_frm->reason_phrase_len;
return 1; return 1;
} }
@ -971,16 +971,16 @@ static int quic_parse_connection_close_app_frame(struct quic_frame *frm, struct
const unsigned char **buf, const unsigned char *end) const unsigned char **buf, const unsigned char *end)
{ {
size_t plen; size_t plen;
struct qf_connection_close_app *cc = &frm->connection_close_app; struct qf_connection_close_app *cc_frm = &frm->connection_close_app;
if (!quic_dec_int(&cc->error_code, buf, end) || if (!quic_dec_int(&cc_frm->error_code, buf, end) ||
!quic_dec_int(&cc->reason_phrase_len, buf, end) || !quic_dec_int(&cc_frm->reason_phrase_len, buf, end) ||
end - *buf < cc->reason_phrase_len) end - *buf < cc_frm->reason_phrase_len)
return 0; return 0;
plen = QUIC_MIN((size_t)cc->reason_phrase_len, sizeof cc->reason_phrase); plen = QUIC_MIN((size_t)cc_frm->reason_phrase_len, sizeof cc_frm->reason_phrase);
memcpy(cc->reason_phrase, *buf, plen); memcpy(cc_frm->reason_phrase, *buf, plen);
*buf += cc->reason_phrase_len; *buf += cc_frm->reason_phrase_len;
return 1; return 1;
} }

View File

@ -189,15 +189,15 @@ void qc_stream_desc_free(struct qc_stream_desc *stream, int closing)
*/ */
frm_node = eb64_first(&stream->acked_frms); frm_node = eb64_first(&stream->acked_frms);
while (frm_node) { while (frm_node) {
struct qf_stream *strm; struct qf_stream *strm_frm;
struct quic_frame *frm; struct quic_frame *frm;
strm = eb64_entry(frm_node, struct qf_stream, offset); strm_frm = eb64_entry(frm_node, struct qf_stream, offset);
frm_node = eb64_next(frm_node); frm_node = eb64_next(frm_node);
eb64_delete(&strm->offset); eb64_delete(&strm_frm->offset);
frm = container_of(strm, struct quic_frame, stream); frm = container_of(strm_frm, struct quic_frame, stream);
qc_release_frm(qc, frm); qc_release_frm(qc, frm);
} }