@@ -1116,11 +1116,43 @@ typedef struct nghttp3_qpack_encoder nghttp3_qpack_encoder;
1116
1116
*
1117
1117
* :macro:`NGHTTP3_ERR_NOMEM`
1118
1118
* 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.
1119
1123
*/
1120
1124
NGHTTP3_EXTERN int nghttp3_qpack_encoder_new (nghttp3_qpack_encoder * * pencoder ,
1121
1125
size_t hard_max_dtable_capacity ,
1122
1126
const nghttp3_mem * mem );
1123
1127
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
+
1124
1156
/**
1125
1157
* @function
1126
1158
*
@@ -1605,7 +1637,8 @@ NGHTTP3_EXTERN void nghttp3_set_debug_vprintf_callback(
1605
1637
typedef struct nghttp3_conn nghttp3_conn ;
1606
1638
1607
1639
#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
1609
1642
1610
1643
/**
1611
1644
* @struct
@@ -1652,6 +1685,21 @@ typedef struct nghttp3_settings {
1652
1685
* Datagrams (see :rfc:`9297`).
1653
1686
*/
1654
1687
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 ;
1655
1703
} nghttp3_settings ;
1656
1704
1657
1705
/**
@@ -1891,8 +1939,47 @@ typedef int (*nghttp3_recv_settings)(nghttp3_conn *conn,
1891
1939
const nghttp3_settings * settings ,
1892
1940
void * conn_user_data );
1893
1941
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
+
1894
1980
#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
1896
1983
1897
1984
/**
1898
1985
* @struct
@@ -1986,6 +2073,28 @@ typedef struct nghttp3_callbacks {
1986
2073
* when SETTINGS frame is received.
1987
2074
*/
1988
2075
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 ;
1989
2098
} nghttp3_callbacks ;
1990
2099
1991
2100
/**
@@ -2106,7 +2215,7 @@ NGHTTP3_EXTERN int nghttp3_conn_bind_qpack_streams(nghttp3_conn *conn,
2106
2215
* control credit (both stream and connection) of underlying QUIC
2107
2216
* connection by that amount. It does not include the amount of data
2108
2217
* 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
2110
2219
* :type:`nghttp3_recv_data` to handle those bytes. If |fin| is
2111
2220
* nonzero, this is the last data from remote endpoint in this stream.
2112
2221
*
@@ -2480,8 +2589,6 @@ typedef struct nghttp3_data_reader {
2480
2589
* This function returns 0 if it succeeds, or one of the following
2481
2590
* negative error codes:
2482
2591
*
2483
- * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
2484
- * |stream_id| identifies unidirectional stream.
2485
2592
* :macro:`NGHTTP3_ERR_CONN_CLOSING`
2486
2593
* Connection is shutting down, and no new stream is allowed.
2487
2594
* :macro:`NGHTTP3_ERR_STREAM_IN_USE`
0 commit comments