return NULL;
}
-/* Parse a QUIC packet starting at <buf>. Data won't be read after <end> even
+/* Parse a QUIC packet starting at <pos>. Data won't be read after <end> even
* if the packet is incomplete. This function will populate fields of <pkt>
* instance, most notably its length. <dgram> is the UDP datagram which
* contains the parsed packet. <l> is the listener instance on which it was
* received.
*
* Returns 0 on success else non-zero. Packet length is guaranteed to be set to
- * the real packet value or to cover all data between <buf> and <end> : this is
+ * the real packet value or to cover all data between <pos> and <end> : this is
* useful to reject a whole datagram.
*/
static int quic_rx_pkt_parse(struct quic_rx_packet *pkt,
- unsigned char *buf, const unsigned char *end,
+ unsigned char *pos, const unsigned char *end,
struct quic_dgram *dgram, struct listener *l)
{
- const unsigned char *beg = buf;
+ const unsigned char *beg = pos;
struct proxy *prx;
struct quic_counters *prx_counters;
* packet with parsed packet number from others.
*/
pkt->pn_node.key = (uint64_t)-1;
- if (end <= buf) {
+ if (end <= pos) {
TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT);
goto drop;
}
/* Fixed bit */
- if (!(*buf & QUIC_PACKET_FIXED_BIT)) {
+ if (!(*pos & QUIC_PACKET_FIXED_BIT)) {
if (!(pkt->flags & QUIC_FL_RX_PACKET_DGRAM_FIRST) &&
- quic_padding_check(buf, end)) {
+ quic_padding_check(pos, end)) {
/* Some browsers may pad the remaining datagram space with null bytes.
* That is what we called add padding out of QUIC packets. Such
* datagrams must be considered as valid. But we can only consume
* the remaining space.
*/
- pkt->len = end - buf;
+ pkt->len = end - pos;
goto drop_silent;
}
}
/* Header form */
- if (!qc_parse_hd_form(pkt, &buf, end)) {
+ if (!qc_parse_hd_form(pkt, &pos, end)) {
TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT);
goto drop;
}
uint64_t len;
TRACE_PROTO("long header packet received", QUIC_EV_CONN_LPKT);
- if (!quic_packet_read_long_header(&buf, end, pkt)) {
+ if (!quic_packet_read_long_header(&pos, end, pkt)) {
TRACE_PROTO("Packet dropped", QUIC_EV_CONN_LPKT);
goto drop;
}
if (pkt->type == QUIC_PACKET_TYPE_INITIAL) {
uint64_t token_len;
- if (!quic_dec_int(&token_len, (const unsigned char **)&buf, end) ||
- end - buf < token_len) {
+ if (!quic_dec_int(&token_len, (const unsigned char **)&pos, end) ||
+ end - pos < token_len) {
TRACE_PROTO("Packet dropped",
QUIC_EV_CONN_LPKT, NULL, NULL, NULL, pkt->version);
goto drop;
goto drop;
}
- pkt->token = buf;
+ pkt->token = pos;
pkt->token_len = token_len;
- buf += pkt->token_len;
+ pos += pkt->token_len;
}
else if (pkt->type != QUIC_PACKET_TYPE_0RTT) {
if (pkt->dcid.len != QUIC_HAP_CID_LEN) {
}
}
- if (!quic_dec_int(&len, (const unsigned char **)&buf, end) ||
- end - buf < len) {
+ if (!quic_dec_int(&len, (const unsigned char **)&pos, end) ||
+ end - pos < len) {
TRACE_PROTO("Packet dropped",
QUIC_EV_CONN_LPKT, NULL, NULL, NULL, pkt->version);
goto drop;
/* Packet Number is stored here. Packet Length totalizes the
* rest of the content.
*/
- pkt->pn_offset = buf - beg;
+ pkt->pn_offset = pos - beg;
pkt->len = pkt->pn_offset + len;
/* RFC 9000. Initial Datagram Size
}
else {
TRACE_PROTO("RX short header packet", QUIC_EV_CONN_LPKT);
- if (end - buf < QUIC_HAP_CID_LEN) {
+ if (end - pos < QUIC_HAP_CID_LEN) {
TRACE_PROTO("RX pkt dropped", QUIC_EV_CONN_LPKT);
goto drop;
}
- memcpy(pkt->dcid.data, buf, QUIC_HAP_CID_LEN);
+ memcpy(pkt->dcid.data, pos, QUIC_HAP_CID_LEN);
pkt->dcid.len = QUIC_HAP_CID_LEN;
/* When multiple QUIC packets are coalesced on the same UDP datagram,
goto drop;
}
- buf += QUIC_HAP_CID_LEN;
+ pos += QUIC_HAP_CID_LEN;
- pkt->pn_offset = buf - beg;
+ pkt->pn_offset = pos - beg;
/* A short packet is the last one of a UDP datagram. */
pkt->len = end - beg;
}