struct connection *conn;
struct {
- /* Number of sent bytes. */
- uint64_t bytes;
/* Number of bytes for prepared packets */
- uint64_t prep_bytes;
+ uint64_t prep;
+ /* Number of sent bytes. */
+ uint64_t tx;
+ /* Number of received bytes. */
+ uint64_t rx;
+ } bytes;
+ struct {
/* Transport parameters sent by the peer */
struct quic_transport_params params;
/* Send buffer used to write datagrams. */
struct buffer buf;
} tx;
struct {
- /* Number of received bytes. */
- uint64_t bytes;
/* Transport parameters the peer will receive */
struct quic_transport_params params;
/* RX buffer */
*/
static inline size_t quic_may_send_bytes(struct quic_conn *qc)
{
- return 3 * qc->rx.bytes - qc->tx.prep_bytes;
+ return 3 * qc->bytes.rx - qc->bytes.prep;
}
/* CRYPTO data buffer handling functions. */
qc->state >= QUIC_HS_ST_COMPLETE)
return 1;
- BUG_ON(qc->tx.prep_bytes > 3 * qc->rx.bytes);
+ BUG_ON(qc->bytes.prep > 3 * qc->bytes.rx);
return 0;
}
TLS_EXTENSION_QUIC_TRANSPORT_PARAMETERS_DRAFT:
TLS_EXTENSION_QUIC_TRANSPORT_PARAMETERS;
/* TX part. */
- qc->tx.bytes = qc->tx.prep_bytes = 0;
+ qc->bytes.tx = qc->bytes.prep = 0;
memset(&qc->tx.params, 0, sizeof(qc->tx.params));
qc->tx.buf = BUF_NULL;
/* RX part. */
- qc->rx.bytes = 0;
+ qc->bytes.rx = 0;
memset(&qc->rx.params, 0, sizeof(qc->rx.params));
qc->rx.buf = b_make(qc->rx.buf.area, QUIC_CONN_RX_BUFSZ, 0, 0);
for (i = 0; i < QCS_MAX_TYPES; i++)
* if this datagram could be associated to a connection.
*/
if (dgram->qc)
- dgram->qc->rx.bytes += dgram->len;
+ dgram->qc->bytes.rx += dgram->len;
/* This must never happen. */
BUG_ON(pos > end);
(unsigned long)pkt->pn_node.key,
quic_pktns_char(qc, pkt->pktns),
(unsigned long long)pkt->in_flight_len);
- chunk_appendf(&trace_buf, " rx.bytes=%llu tx.bytes=%llu",
- (unsigned long long)qc->rx.bytes,
- (unsigned long long)qc->tx.bytes);
+ chunk_appendf(&trace_buf, " bytes.rx=%llu bytes.tx=%llu",
+ (unsigned long long)qc->bytes.rx,
+ (unsigned long long)qc->bytes.tx);
list_for_each_entry(frm, &pkt->frms, list) {
chunk_appendf(&trace_buf, " frm@%p", frm);
chunk_frm_appendf(&trace_buf, frm);
}
b_del(buf, dglen + headlen);
- qc->tx.bytes += tmpbuf.data;
+ qc->bytes.tx += tmpbuf.data;
time_sent = now_ms;
for (pkt = first_pkt; pkt; pkt = next_pkt) {
/* Consume a packet number */
qel->pktns->tx.next_pn++;
- qc->tx.prep_bytes += pkt->len;
- if (qc->tx.prep_bytes >= 3 * qc->rx.bytes && !quic_peer_validated_addr(qc)) {
+ qc->bytes.prep += pkt->len;
+ if (qc->bytes.prep >= 3 * qc->bytes.rx && !quic_peer_validated_addr(qc)) {
qc->flags |= QUIC_FL_CONN_ANTI_AMPLIFICATION_REACHED;
TRACE_PROTO("anti-amplification limit reached", QUIC_EV_CONN_TXPKT, qc);
}