Forward stream 0 data to TLS backend after handshake
Data received in Stream 0 STREAM frame in a protected packet is now
forwarded to TLS backend.  Those data received in Stream 0 STREAM
frame in a unprotected packet after handshake is ignored as before.
@@ -2443,13 +2443,9 @@ static int conn_recv_stream(ngtcp2_conn *conn, const ngtcp2_stream *fr) {
uint64_t rx_offset, fr_end_offset;
int local_stream;
- /* TODO What to do if we get data for stream 0? */
- if (fr->stream_id == 0) {
- if (fr->fin) {
+ if (fr->stream_id == 0 && fr->fin) {
return NGTCP2_ERR_PROTO;
}
- return 0;
- }
if (!fr->fin && fr->datalen == 0) {
return NGTCP2_ERR_FRAME_FORMAT;
@@ -2501,6 +2497,7 @@ static int conn_recv_stream(ngtcp2_conn *conn, const ngtcp2_stream *fr) {
if (strm->last_rx_offset < fr_end_offset) {
size_t datalen = fr_end_offset - strm->last_rx_offset;
+ if (strm->stream_id != 0) {
if (conn_max_data_violated(conn, datalen)) {
return NGTCP2_ERR_FLOW_CONTROL;
}
@@ -2508,6 +2505,7 @@ static int conn_recv_stream(ngtcp2_conn *conn, const ngtcp2_stream *fr) {
ngtcp2_increment_offset(&conn->rx_offset_high, &conn->rx_offset_low,
datalen);
}
+ }
if (fr->fin) {
if (strm->flags & NGTCP2_STRM_FLAG_SHUT_RD) {
@@ -2578,7 +2576,12 @@ static int conn_recv_stream(ngtcp2_conn *conn, const ngtcp2_stream *fr) {
return rv;
}
+ if (strm->stream_id == 0) {
+ rv =
+ ngtcp2_conn_emit_pending_recv_handshake(conn, conn->strm0, rx_offset);
+ } else {
rv = conn_emit_pending_stream_data(conn, strm, rx_offset);
+ }
if (rv != 0) {
return rv;
}
