struct buffer *buf = &qcc->tx.qstrm_buf;
unsigned char *pos, *old, *end;
size_t ret;
+ /* Record size field length */
+ const int lensz = quic_int_getsize(quic_int_cap_length(b_size(buf)));
TRACE_ENTER(QMUX_EV_QCC_SEND, qcc->conn);
}
}
- b_reset(buf);
list_for_each_entry_safe(frm, frm_old, frms, list) {
loop:
split_frm = next_frm = NULL;
b_reset(buf);
- old = pos = (unsigned char *)b_orig(buf);
+ /* Reserve 4 bytes for the record header. */
+ old = pos = (unsigned char *)b_orig(buf) + lensz;
end = (unsigned char *)b_wrap(buf);
BUG_ON(!frm);
qc_build_frm(frm, &pos, end, NULL);
BUG_ON(pos - old > global.tune.bufsize);
BUG_ON(pos == old);
+
+ /* Encode record header and save built payload. */
+ ret = b_quic_enc_int(buf, pos - old, lensz);
+ BUG_ON(!ret);
b_add(buf, pos - old);
ret = conn->xprt->snd_buf(conn, conn->xprt_ctx, buf, b_data(buf), NULL, 0, 0);
struct buffer *buf = &ctx->txbuf;
unsigned char *pos, *old, *end;
size_t sent;
- int ret;
+ int ret, lensz;
if (!conn_ctrl_ready(conn))
goto fail;
/* Small buf is sufficient for our transport parameters. */
if (!b_size(buf) && !b_alloc_small(buf))
goto fail;
+ /* Record size field length */
+ lensz = quic_int_getsize(quic_int_cap_length(b_size(buf)));
if (!b_data(buf)) {
- old = pos = (unsigned char *)b_orig(buf);
+ old = pos = (unsigned char *)b_orig(buf) + lensz;
end = (unsigned char *)b_wrap(buf);
ret = qc_build_frm(&frm, &pos, end, NULL);
- BUG_ON(!ret);
+ BUG_ON(!ret); /* should never fail */
+
+ ret = b_quic_enc_int(buf, pos - old, lensz);
+ BUG_ON(!ret); /* should never fail */
b_add(buf, pos - old);
}