@@ -1116,11 +1116,43 @@ typedef struct nghttp3_qpack_encoder nghttp3_qpack_encoder;
11161116 *
11171117 * :macro:`NGHTTP3_ERR_NOMEM`
11181118 * Out of memory.
1119+ *
1120+ * See also `nghttp3_qpack_encoder_new2`. This function calls
1121+ * `nghttp3_qpack_encoder_new2` with the given parameters and 0 as
1122+ * seed.
11191123 */
11201124NGHTTP3_EXTERN int nghttp3_qpack_encoder_new (nghttp3_qpack_encoder * * pencoder ,
11211125 size_t hard_max_dtable_capacity ,
11221126 const nghttp3_mem * mem );
11231127
1128+ /**
1129+ * @function
1130+ *
1131+ * `nghttp3_qpack_encoder_new2` initializes QPACK encoder. |pencoder|
1132+ * must be non-NULL pointer. |hard_max_dtable_capacity| is the upper
1133+ * bound of the dynamic table capacity. |seed| must be unpredictable
1134+ * value, and is used to seed the internal data structure. |mem| is a
1135+ * memory allocator. This function allocates memory for
1136+ * :type:`nghttp3_qpack_encoder` itself, and assigns its pointer to
1137+ * |*pencoder| if it succeeds.
1138+ *
1139+ * The maximum dynamic table capacity is still 0. In order to change
1140+ * the maximum dynamic table capacity, call
1141+ * `nghttp3_qpack_encoder_set_max_dtable_capacity`.
1142+ *
1143+ * This function returns 0 if it succeeds, or one of the following
1144+ * negative error codes:
1145+ *
1146+ * :macro:`NGHTTP3_ERR_NOMEM`
1147+ * Out of memory.
1148+ *
1149+ * This function is available since v1.11.0.
1150+ */
1151+ NGHTTP3_EXTERN int nghttp3_qpack_encoder_new2 (nghttp3_qpack_encoder * * pencoder ,
1152+ size_t hard_max_dtable_capacity ,
1153+ uint64_t seed ,
1154+ const nghttp3_mem * mem );
1155+
11241156/**
11251157 * @function
11261158 *
@@ -1605,7 +1637,8 @@ NGHTTP3_EXTERN void nghttp3_set_debug_vprintf_callback(
16051637typedef struct nghttp3_conn nghttp3_conn ;
16061638
16071639#define NGHTTP3_SETTINGS_V1 1
1608- #define NGHTTP3_SETTINGS_VERSION NGHTTP3_SETTINGS_V1
1640+ #define NGHTTP3_SETTINGS_V2 2
1641+ #define NGHTTP3_SETTINGS_VERSION NGHTTP3_SETTINGS_V2
16091642
16101643/**
16111644 * @struct
@@ -1652,6 +1685,21 @@ typedef struct nghttp3_settings {
16521685 * Datagrams (see :rfc:`9297`).
16531686 */
16541687 uint8_t h3_datagram ;
1688+ /* The following fields have been added since NGHTTP3_SETTINGS_V2. */
1689+ /**
1690+ * :member:`origin_list`, if set, must contain a serialized HTTP/3
1691+ * ORIGIN frame (see :rfc:`9412`) payload. The ORIGIN frame payload
1692+ * is a sequence of zero or more of a length prefixed byte string.
1693+ * The length is encoded in 2 bytes in network byte order. If
1694+ * :member:`origin_list->len <nghttp3_vec.len>` is zero, an empty
1695+ * ORIGIN frame is sent. An application must keep the buffer
1696+ * pointed by :member:`origin_list->base <nghttp3_vec.base>` alive
1697+ * until the :type:`nghttp3_conn` to which this field was passed is
1698+ * freed by `nghttp3_conn_del`. The object pointed to by this field
1699+ * is copied internally, and does not need to be kept alive. Only
1700+ * server uses this field. This field is available since v1.11.0.
1701+ */
1702+ const nghttp3_vec * origin_list ;
16551703} nghttp3_settings ;
16561704
16571705/**
@@ -1891,8 +1939,47 @@ typedef int (*nghttp3_recv_settings)(nghttp3_conn *conn,
18911939 const nghttp3_settings * settings ,
18921940 void * conn_user_data );
18931941
1942+ /**
1943+ * @functypedef
1944+ *
1945+ * :type:`nghttp3_recv_origin` is a callback function which is invoked
1946+ * when a single origin in ORIGIN frame is received. |origin| is a
1947+ * received origin of length |originlen|. |originlen| never be 0.
1948+ *
1949+ * The implementation of this callback must return 0 if it succeeds.
1950+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
1951+ * caller immediately. Any values other than 0 is treated as
1952+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
1953+ */
1954+ typedef int (* nghttp3_recv_origin )(nghttp3_conn * conn , const uint8_t * origin ,
1955+ size_t originlen , void * conn_user_data );
1956+
1957+ /**
1958+ * @functypedef
1959+ *
1960+ * :type:`nghttp3_end_origin` is a callback function which is invoked
1961+ * when an ORIGIN frame has been completely processed.
1962+ *
1963+ * The implementation of this callback must return 0 if it succeeds.
1964+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
1965+ * caller immediately. Any values other than 0 is treated as
1966+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
1967+ */
1968+ typedef int (* nghttp3_end_origin )(nghttp3_conn * conn , void * conn_user_data );
1969+
1970+ /**
1971+ * @functypedef
1972+ *
1973+ * :type:`nghttp3_rand` is a callback function which is invoked when
1974+ * unpredictable data of |destlen| bytes are needed. The
1975+ * implementation must write unpredictable data of |destlen| bytes
1976+ * into the buffer pointed by |dest|.
1977+ */
1978+ typedef void (* nghttp3_rand )(uint8_t * dest , size_t destlen );
1979+
18941980#define NGHTTP3_CALLBACKS_V1 1
1895- #define NGHTTP3_CALLBACKS_VERSION NGHTTP3_CALLBACKS_V1
1981+ #define NGHTTP3_CALLBACKS_V2 2
1982+ #define NGHTTP3_CALLBACKS_VERSION NGHTTP3_CALLBACKS_V2
18961983
18971984/**
18981985 * @struct
@@ -1986,6 +2073,28 @@ typedef struct nghttp3_callbacks {
19862073 * when SETTINGS frame is received.
19872074 */
19882075 nghttp3_recv_settings recv_settings ;
2076+ /* The following fields have been added since NGHTTP3_CALLBACKS_V2. */
2077+ /**
2078+ * :member:`recv_origin` is a callback function which is invoked
2079+ * when a single origin in an ORIGIN frame is received. This field
2080+ * is available since v1.11.0.
2081+ */
2082+ nghttp3_recv_origin recv_origin ;
2083+ /**
2084+ * :member:`end_origin` is a callback function which is invoked when
2085+ * an ORIGIN frame has been completely processed. This field is
2086+ * available since v1.11.0.
2087+ */
2088+ nghttp3_end_origin end_origin ;
2089+ /**
2090+ * :member:`rand` is a callback function which is invoked when
2091+ * unpredictable data are needed. Although this field is optional
2092+ * due to the backward compatibility, it is recommended to specify
2093+ * this field to harden the runtime behavior against suspicious
2094+ * activities of a remote endpoint. This field is available since
2095+ * v1.11.0.
2096+ */
2097+ nghttp3_rand rand ;
19892098} nghttp3_callbacks ;
19902099
19912100/**
@@ -2106,7 +2215,7 @@ NGHTTP3_EXTERN int nghttp3_conn_bind_qpack_streams(nghttp3_conn *conn,
21062215 * control credit (both stream and connection) of underlying QUIC
21072216 * connection by that amount. It does not include the amount of data
21082217 * carried by DATA frame which contains application data (excluding
2109- * any control or QPACK unidirectional streams) . See
2218+ * any control or QPACK unidirectional streams). See
21102219 * :type:`nghttp3_recv_data` to handle those bytes. If |fin| is
21112220 * nonzero, this is the last data from remote endpoint in this stream.
21122221 *
@@ -2480,8 +2589,6 @@ typedef struct nghttp3_data_reader {
24802589 * This function returns 0 if it succeeds, or one of the following
24812590 * negative error codes:
24822591 *
2483- * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
2484- * |stream_id| identifies unidirectional stream.
24852592 * :macro:`NGHTTP3_ERR_CONN_CLOSING`
24862593 * Connection is shutting down, and no new stream is allowed.
24872594 * :macro:`NGHTTP3_ERR_STREAM_IN_USE`
0 commit comments