ngtcp2_pkt_decode_hd_long

Synopsis

#include <ngtcp2/ngtcp2.h>

ngtcp2_ssize ngtcp2_pkt_decode_hd_long(ngtcp2_pkt_hd *dest, const uint8_t *pkt, size_t pktlen)

ngtcp2_pkt_decode_hd_long() decodes QUIC long packet header in pkt of length pktlen. This function only parses the input just before packet number field.

This function does not verify that length field is correct. In other words, this function succeeds even if length > pktlen.

This function can handle Connection ID up to NGTCP2_MAX_CIDLEN. Consider to use ngtcp2_pkt_decode_version_cid() to get longer Connection ID.

This function handles Version Negotiation specially. If version field is 0, pkt must contain Version Negotiation packet. Version Negotiation packet has random type in wire format. For convenience, this function sets ngtcp2_pkt_type.NGTCP2_PKT_VERSION_NEGOTIATION to dest->type, clears NGTCP2_PKT_FLAG_LONG_FORM flag from dest->flags, and sets 0 to dest->len. Version Negotiation packet occupies a single packet.

It stores the result in the object pointed by dest, and returns the number of bytes decoded to read the packet header if it succeeds, or one of the following error codes:

NGTCP2_ERR_INVALID_ARGUMENT

Packet is too short; or it is not a long header