
ngtcp2_pkt_decode_hd_long
=========================

Synopsis
--------

*#include <ngtcp2/ngtcp2.h>*

.. function:: 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
    :macro:`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
    :enum:`ngtcp2_pkt_type.NGTCP2_PKT_VERSION_NEGOTIATION` to
    :member:`dest->type <ngtcp2_pkt_hd.type>`, clears
    :macro:`NGTCP2_PKT_FLAG_LONG_FORM` flag from :member:`dest->flags
    <ngtcp2_pkt_hd.flags>`, and sets 0 to :member:`dest->len
    <ngtcp2_pkt_hd.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:
    
    :macro:`NGTCP2_ERR_INVALID_ARGUMENT`
        Packet is too short; or it is not a long header
