/* Initialize an uni-stream <qcs> by reading its type from <b>.
*
- * Returns 0 on success else non-zero.
+ * Returns the count of consumed bytes or a negative error code.
*/
-static int h3_init_uni_stream(struct h3c *h3c, struct qcs *qcs,
- struct buffer *b)
+static ssize_t h3_init_uni_stream(struct h3c *h3c, struct qcs *qcs,
+ struct buffer *b)
{
/* decode unidirectional stream type */
struct h3s *h3s = qcs->ctx;
case H3_UNI_S_T_CTRL:
if (h3c->flags & H3_CF_UNI_CTRL_SET) {
qcc_emit_cc_app(qcs->qcc, H3_STREAM_CREATION_ERROR);
- return 1;
+ return -1;
}
h3c->flags |= H3_CF_UNI_CTRL_SET;
h3s->type = H3S_T_CTRL;
case H3_UNI_S_T_QPACK_DEC:
if (h3c->flags & H3_CF_UNI_QPACK_DEC_SET) {
qcc_emit_cc_app(qcs->qcc, H3_STREAM_CREATION_ERROR);
- return 1;
+ return -1;
}
h3c->flags |= H3_CF_UNI_QPACK_DEC_SET;
h3s->type = H3S_T_QPACK_DEC;
case H3_UNI_S_T_QPACK_ENC:
if (h3c->flags & H3_CF_UNI_QPACK_ENC_SET) {
qcc_emit_cc_app(qcs->qcc, H3_STREAM_CREATION_ERROR);
- return 1;
+ return -1;
}
h3c->flags |= H3_CF_UNI_QPACK_ENC_SET;
h3s->type = H3S_T_QPACK_ENC;
* streams that have unknown or unsupported types.
*/
qcs->flags |= QC_SF_READ_ABORTED;
- return 1;
+ return -1;
};
h3s->flags |= H3_SF_UNI_INIT;
TRACE_LEAVE(H3_EV_H3S_NEW, qcs->qcc->conn, qcs);
- return 0;
+ return len;
}
/* Parse an uni-stream <qcs> from <rxbuf> which does not contains H3 frames.
* This may be used for QPACK encoder/decoder streams for example.
*
- * Returns 0 on success else non-zero.
+ * Returns the number of consumed bytes or a negative error code.
*/
-static int h3_parse_uni_stream_no_h3(struct qcs *qcs, struct buffer *b)
+static ssize_t h3_parse_uni_stream_no_h3(struct qcs *qcs, struct buffer *b)
{
struct h3s *h3s = qcs->ctx;
switch (h3s->type) {
case H3S_T_QPACK_DEC:
if (qpack_decode_dec(qcs, NULL))
- return 1;
+ return -1;
break;
case H3S_T_QPACK_ENC:
if (qpack_decode_enc(qcs, NULL))
- return 1;
+ return -1;
break;
case H3S_T_UNKNOWN:
default:
ABORT_NOW();
}
+ /* TODO adjust return code */
return 0;
}
* in a local HTX buffer and transfer to the stream connector layer. <fin> must be
* set if this is the last data to transfer from this stream.
*
- * Returns the number of bytes handled or a negative error code.
+ * Returns the number of consumed bytes or a negative error code.
*/
-static int h3_headers_to_htx(struct qcs *qcs, const struct buffer *buf,
- uint64_t len, char fin)
+static ssize_t h3_headers_to_htx(struct qcs *qcs, const struct buffer *buf,
+ uint64_t len, char fin)
{
struct buffer htx_buf = BUF_NULL;
struct buffer *tmp = get_trash_chunk();
* HTX buffer. <fin> must be set if this is the last data to transfer from this
* stream.
*
- * Returns the number of bytes handled or a negative error code.
+ * Returns the number of consumed bytes or a negative error code.
*/
-static int h3_data_to_htx(struct qcs *qcs, const struct buffer *buf,
- uint64_t len, char fin)
+static ssize_t h3_data_to_htx(struct qcs *qcs, const struct buffer *buf,
+ uint64_t len, char fin)
{
struct buffer *appbuf;
struct htx *htx = NULL;
/* Parse a SETTINGS frame of length <len> of payload <buf>.
*
- * Returns the number of bytes handled or a negative error code.
+ * Returns the number of consumed bytes or a negative error code.
*/
-static size_t h3_parse_settings_frm(struct h3c *h3c, const struct buffer *buf,
- size_t len)
+static ssize_t h3_parse_settings_frm(struct h3c *h3c, const struct buffer *buf,
+ size_t len)
{
struct buffer b;
uint64_t id, value;
*
* Returns 0 on success else non-zero.
*/
-static int h3_decode_qcs(struct qcs *qcs, struct buffer *b, int fin)
+static ssize_t h3_decode_qcs(struct qcs *qcs, struct buffer *b, int fin)
{
struct h3s *h3s = qcs->ctx;
struct h3c *h3c = h3s->h3c;
- ssize_t ret;
+ ssize_t total = 0, ret;
h3_debug_printf(stderr, "%s: STREAM ID: %lu\n", __func__, qcs->id);
if (!b_data(b))
return 0;
if (quic_stream_is_uni(qcs->id) && !(h3s->flags & H3_SF_UNI_INIT)) {
- if (h3_init_uni_stream(h3c, qcs, b))
- return 1;
+ if ((ret = h3_init_uni_stream(h3c, qcs, b)) < 0)
+ return -1;
+
+ total += ret;
}
if (quic_stream_is_uni(qcs->id) && (h3s->flags & H3_SF_UNI_NO_H3)) {
/* For non-h3 STREAM, parse it and return immediately. */
- if (h3_parse_uni_stream_no_h3(qcs, b))
- return 1;
- return 0;
+ if ((ret = h3_parse_uni_stream_no_h3(qcs, b)) < 0)
+ return -1;
+
+ total += ret;
+ return total;
}
while (b_data(b) && !(qcs->flags & QC_SF_DEM_FULL)) {
h3s->demux_frame_type = ftype;
h3s->demux_frame_len = flen;
+ total += hlen;
if (!h3_is_frame_valid(h3c, qcs, ftype)) {
qcc_emit_cc_app(qcs->qcc, H3_FRAME_UNEXPECTED);
BUG_ON(h3s->demux_frame_len < ret);
h3s->demux_frame_len -= ret;
b_del(b, ret);
+ total += ret;
}
}
* However, currently, io-cb of MUX does not handle Rx.
*/
- return 0;
+ return total;
}
/* Returns buffer for data sending.