Skip to content

Commit 804594d

Browse files
committed
MINOR: quic: extend return value of CRYPTO parsing
1 parent 7fedb62 commit 804594d

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/quic_rx.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -616,16 +616,20 @@ static int qc_handle_strm_frm(struct quic_rx_packet *pkt,
616616
return !ret;
617617
}
618618

619-
/* Parse <frm> CRYPTO frame coming with <pkt> packet at <qel> <qc> connectionn.
620-
* Returns 1 if succeeded, 0 if not. Also set <*fast_retrans> to 1 if the
621-
* speed up handshake completion may be run after having received duplicated
622-
* CRYPTO data.
619+
/* Parse <frm> CRYPTO frame coming with <pkt> packet at <qel> <qc> connection.
620+
*
621+
* Returns 0 on success or a negative error code. A positive value is used to
622+
* indicate that the current frame cannot be handled immediately, but it could
623+
* be solved by running a new packet parsing iteration.
624+
*
625+
* Also set <*fast_retrans> as output parameter to 1 if the speed up handshake
626+
* completion may be run after having received duplicated CRYPTO data.
623627
*/
624628
static int qc_handle_crypto_frm(struct quic_conn *qc,
625629
struct qf_crypto *crypto_frm, struct quic_rx_packet *pkt,
626630
struct quic_enc_level *qel, int *fast_retrans)
627631
{
628-
int ret = 0;
632+
int ret = -1;
629633
enum ncb_ret ncb_ret;
630634
/* XXX TO DO: <cfdebug> is used only for the traces. */
631635
struct quic_rx_crypto_frm cfdebug = {
@@ -676,6 +680,7 @@ static int qc_handle_crypto_frm(struct quic_conn *qc,
676680
else if (ncb_ret == NCB_RET_GAP_SIZE) {
677681
TRACE_ERROR("cannot bufferize frame due to gap size limit",
678682
QUIC_EV_CONN_PRSHPKT, qc);
683+
ret = 1;
679684
}
680685
goto leave;
681686
}
@@ -687,7 +692,7 @@ static int qc_handle_crypto_frm(struct quic_conn *qc,
687692
}
688693

689694
done:
690-
ret = 1;
695+
ret = 0;
691696
leave:
692697
TRACE_LEAVE(QUIC_EV_CONN_PRSHPKT, qc);
693698
return ret;
@@ -770,7 +775,7 @@ static int qc_parse_pkt_frms(struct quic_conn *qc, struct quic_rx_packet *pkt,
770775
{
771776
struct quic_frame frm;
772777
const unsigned char *pos, *end;
773-
int fast_retrans = 0;
778+
int fast_retrans = 0, ret = 0;
774779

775780
TRACE_ENTER(QUIC_EV_CONN_PRSHPKT, qc);
776781
/* Skip the AAD */
@@ -843,9 +848,12 @@ static int qc_parse_pkt_frms(struct quic_conn *qc, struct quic_rx_packet *pkt,
843848
break;
844849
}
845850
case QUIC_FT_CRYPTO:
846-
if (!qc_handle_crypto_frm(qc, &frm.crypto, pkt, qel, &fast_retrans))
851+
{
852+
ret = qc_handle_crypto_frm(qc, &frm.crypto, pkt, qel, &fast_retrans);
853+
if (ret != 0)
847854
goto err;
848855
break;
856+
}
849857
case QUIC_FT_NEW_TOKEN:
850858
/* TODO */
851859
break;

0 commit comments

Comments
 (0)