
ngtcp2_conn_read_pkt
====================

Synopsis
--------

*#include <ngtcp2/ngtcp2.h>*

.. function:: int ngtcp2_conn_read_pkt(ngtcp2_conn *conn, const ngtcp2_path *path, const ngtcp2_pkt_info *pi, const uint8_t *pkt, size_t pktlen, ngtcp2_tstamp ts)

    
    `ngtcp2_conn_read_pkt` decrypts QUIC packet given in *pkt* of
    length *pktlen* and processes it.  *path* is the network path the
    packet is delivered and must not be ``NULL``.  *pi* is packet
    metadata and may be ``NULL``. This function performs QUIC handshake
    as well.
    
    This function must not be called from inside the callback
    functions.
    
    This function returns 0 if it succeeds, or one of the following
    negative error codes:
    
    :macro:`NGTCP2_ERR_RETRY`
       Server must perform address validation by sending Retry packet
       (see `ngtcp2_crypto_write_retry` and `ngtcp2_pkt_write_retry`),
       and discard the connection state.  Client application does not
       get this error code.
    :macro:`NGTCP2_ERR_DROP_CONN`
       Server application must drop the connection silently (without
       sending any CONNECTION_CLOSE frame), and discard connection
       state.  Client application does not get this error code.
    :macro:`NGTCP2_ERR_DRAINING`
       A connection has entered the draining state, and no further
       packet transmission is allowed.
    :macro:`NGTCP2_ERR_CLOSING`
       A connection has entered the closing state, and no further
       packet transmission is allowed.  Calling
       `ngtcp2_conn_write_connection_close` makes a connection enter
       this state.
    :macro:`NGTCP2_ERR_CRYPTO`
       An error happened in TLS stack.  `ngtcp2_conn_get_tls_alert`
       returns TLS alert if set.
    
    If any other negative error is returned, call
    `ngtcp2_conn_write_connection_close` to get terminal packet, and
    sending it makes QUIC connection enter the closing state.
