ngtcp2_pkt_decode_version_cid ============================= Synopsis -------- *#include * .. function:: 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 unlike `ngtcp2_pkt_decode_hd_long` or `ngtcp2_pkt_decode_hd_short` which are only capable of handling Connection ID less than or equal to :macro:`NGTCP2_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 :member:`dest->version `. It also extracts the pointer to the Destination Connection ID and its length, and assigns them to :member:`dest->dcid ` and :member:`dest->dcidlen ` respectively. Similarly, it extracts the pointer to the Source Connection ID and its length, and assigns them to :member:`dest->scid ` and :member:`dest->scidlen ` respectively. *short_dcidlen* is ignored. If the given packet is Short header packet, :member:`dest->version ` will be 0, :member:`dest->scid ` will be ``NULL``, and :member:`dest->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 to :member:`dest->dcid `. *short_dcidlen* is assigned to :member:`dest->dcidlen `. If Version Negotiation is required, this function returns :macro:`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: :macro:`NGTCP2_ERR_INVALID_ARGUMENT` The function could not decode the packet header. :macro:`NGTCP2_ERR_VERSION_NEGOTIATION` Version Negotiation packet should be sent.