ngtcp2_pkt_decode_version_cid
Synopsis
#include <ngtcp2/ngtcp2.h>
-
int ngtcp2_pkt_decode_version_cid(ngtcp2_version_cid *dest, const uint8_t *data, size_t datalen, size_t short_dcidlen)
ngtcp2_pkt_decode_version_cid()
extracts QUIC version, Destination Connection ID and Source Connection ID from the packet pointed by data of length datalen. This function can handle Connection ID up to 255 bytes unlikengtcp2_pkt_decode_hd_long()
orngtcp2_pkt_decode_hd_short()
which are only capable of handling Connection ID less than or equal toNGTCP2_MAX_CIDLEN
. Longer Connection ID is only valid if the version is unsupported QUIC version.If the given packet is Long header packet, this function extracts the version from the packet, and assigns it to
dest->version
. It also extracts the pointer to the Destination Connection ID and its length, and assigns them todest->dcid
anddest->dcidlen
respectively. Similarly, it extracts the pointer to the Source Connection ID and its length, and assigns them todest->scid
anddest->scidlen
respectively. short_dcidlen is ignored.If the given packet is Short header packet,
dest->version
will be 0,dest->scid
will beNULL
, anddest->scidlen
will be 0. Because the Short header packet does not have the length of Destination Connection ID, the caller has to pass the length in short_dcidlen. This function extracts the pointer to the Destination Connection ID, and assigns it todest->dcid
. short_dcidlen is assigned todest->dcidlen
.If Version Negotiation is required, this function returns
NGTCP2_ERR_VERSION_NEGOTIATION
. Unlike the other error cases, all fields of dest are assigned as described above.This function returns 0 if it succeeds. Otherwise, one of the following negative error code:
NGTCP2_ERR_INVALID_ARGUMENT
The function could not decode the packet header.
NGTCP2_ERR_VERSION_NEGOTIATION
Version Negotiation packet should be sent.