@@ -81,6 +81,59 @@ extern "C" {
8181 */ 
8282typedef  ptrdiff_t  nghttp3_ssize ;
8383
84+ /** 
85+  * @typedef 
86+  * 
87+  * :type:`nghttp3_tstamp` is a timestamp with nanosecond resolution. 
88+  * ``UINT64_MAX`` is an invalid value, and it is often used to 
89+  * indicate that no value is set.  This type is available since 
90+  * v1.12.0. 
91+  */ 
92+ typedef  uint64_t  nghttp3_tstamp ;
93+ 
94+ /** 
95+  * @typedef 
96+  * 
97+  * :type:`nghttp3_duration` is a period of time in nanosecond 
98+  * resolution.  ``UINT64_MAX`` is an invalid value, and it is often 
99+  * used to indicate that no value is set.  This type is available 
100+  * since v1.12.0. 
101+  */ 
102+ typedef  uint64_t  nghttp3_duration ;
103+ 
104+ /** 
105+  * @macro 
106+  * 
107+  * :macro:`NGHTTP3_NANOSECONDS` is a count of tick which corresponds 
108+  * to 1 nanosecond.  This macro is available since v1.12.0. 
109+  */ 
110+ #define  NGHTTP3_NANOSECONDS  ((nghttp3_duration)1ULL)
111+ 
112+ /** 
113+  * @macro 
114+  * 
115+  * :macro:`NGHTTP3_MICROSECONDS` is a count of tick which corresponds 
116+  * to 1 microsecond.  This macro is available since v1.12.0. 
117+  */ 
118+ #define  NGHTTP3_MICROSECONDS  ((nghttp3_duration)(1000ULL * NGHTTP3_NANOSECONDS))
119+ 
120+ /** 
121+  * @macro 
122+  * 
123+  * :macro:`NGHTTP3_MILLISECONDS` is a count of tick which corresponds 
124+  * to 1 millisecond.  This macro is available since v1.12.0. 
125+  */ 
126+ #define  NGHTTP3_MILLISECONDS                                                    \
127+   ((nghttp3_duration)(1000ULL * NGHTTP3_MICROSECONDS))
128+ 
129+ /** 
130+  * @macro 
131+  * 
132+  * :macro:`NGHTTP3_SECONDS` is a count of tick which corresponds to 1 
133+  * second.  This macro is available since v1.12.0. 
134+  */ 
135+ #define  NGHTTP3_SECONDS  ((nghttp3_duration)(1000ULL * NGHTTP3_MILLISECONDS))
136+ 
84137/** 
85138 * @macro 
86139 * 
@@ -264,6 +317,14 @@ typedef ptrdiff_t nghttp3_ssize;
264317 * allowed. 
265318 */ 
266319#define  NGHTTP3_ERR_H3_STREAM_CREATION_ERROR  -609
320+ /** 
321+  * @macro 
322+  * 
323+  * :macro:`NGHTTP3_ERR_H3_EXCESSIVE_LOAD` indicates that a local 
324+  * endpoint detected that its remote endpoint is exhibiting a behavior 
325+  * that might generating excessive load. 
326+  */ 
327+ #define  NGHTTP3_ERR_H3_EXCESSIVE_LOAD  -610
267328/** 
268329 * @macro 
269330 * 
@@ -1638,7 +1699,8 @@ typedef struct nghttp3_conn nghttp3_conn;
16381699
16391700#define  NGHTTP3_SETTINGS_V1  1
16401701#define  NGHTTP3_SETTINGS_V2  2
1641- #define  NGHTTP3_SETTINGS_VERSION  NGHTTP3_SETTINGS_V2
1702+ #define  NGHTTP3_SETTINGS_V3  3
1703+ #define  NGHTTP3_SETTINGS_VERSION  NGHTTP3_SETTINGS_V3
16421704
16431705/** 
16441706 * @struct 
@@ -1700,6 +1762,24 @@ typedef struct nghttp3_settings {
17001762   * server uses this field.  This field is available since v1.11.0. 
17011763   */ 
17021764  const  nghttp3_vec  * origin_list ;
1765+   /* The following fields have been added since NGHTTP3_SETTINGS_V3. */ 
1766+   /** 
1767+    * :member:`glitch_ratelim_burst` is the maximum number of tokens 
1768+    * available to "glitch" rate limiter.  "glitch" is a suspicious 
1769+    * activity from a remote endpoint.  If detected, certain amount of 
1770+    * tokens are consumed.  If no tokens are available to consume, the 
1771+    * connection is closed.  The rate of token generation is specified 
1772+    * by :member:`glitch_ratelim_rate`.  This feature is enabled only 
1773+    * when `nghttp3_conn_read_stream2` is used.  This field has been 
1774+    * available since v1.12.0. 
1775+    */ 
1776+   uint64_t  glitch_ratelim_burst ;
1777+   /** 
1778+    * :member:`glitch_ratelim_rate` is the number of tokens generated 
1779+    * per second.  See :member:`glitch_ratelim_burst` for "glitch" rate 
1780+    * limiter.  This field has been available since v1.12.0. 
1781+    */ 
1782+   uint64_t  glitch_ratelim_rate ;
17031783} nghttp3_settings ;
17041784
17051785/** 
@@ -2113,6 +2193,10 @@ typedef struct nghttp3_callbacks {
21132193 *   <nghttp3_settings.qpack_blocked_streams>` = 0 
21142194 * - :member:`enable_connect_protocol 
21152195 *   <nghttp3_settings.enable_connect_protocol>` = 0 
2196+  * - :member:`glitch_ratelim_burst 
2197+  *   <nghttp3_settings.glitch_ratelim_burst>` = 1000 
2198+  * - :member:`glitch_ratelim_rate 
2199+  *   <nghttp3_settings.glitch_ratelim_rate>` = 33 
21162200 */ 
21172201NGHTTP3_EXTERN  void 
21182202nghttp3_settings_default_versioned (int  settings_version ,
@@ -2209,6 +2293,11 @@ NGHTTP3_EXTERN int nghttp3_conn_bind_qpack_streams(nghttp3_conn *conn,
22092293/** 
22102294 * @function 
22112295 * 
2296+  * .. warning:: 
2297+  * 
2298+  *   Deprecated since v1.12.0.  Use `nghttp3_conn_read_stream2` 
2299+  *   instead. 
2300+  * 
22122301 * `nghttp3_conn_read_stream` reads data |src| of length |srclen| on 
22132302 * stream identified by |stream_id|.  It returns the number of bytes 
22142303 * consumed.  The "consumed" means that application can increase flow 
@@ -2237,6 +2326,42 @@ NGHTTP3_EXTERN nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn,
22372326                                                      const  uint8_t  * src ,
22382327                                                      size_t  srclen , int  fin );
22392328
2329+ /** 
2330+  * @function 
2331+  * 
2332+  * `nghttp3_conn_read_stream2` reads data |src| of length |srclen| on 
2333+  * stream identified by |stream_id|.  It returns the number of bytes 
2334+  * consumed.  The "consumed" means that application can increase flow 
2335+  * control credit (both stream and connection) of underlying QUIC 
2336+  * connection by that amount.  It does not include the amount of data 
2337+  * carried by DATA frame which contains application data (excluding 
2338+  * any control or QPACK unidirectional streams).  See 
2339+  * :type:`nghttp3_recv_data` to handle those bytes.  If |fin| is 
2340+  * nonzero, this is the last data from remote endpoint in this stream. 
2341+  * |ts| is the current timestamp, and must be non-decreasing.  It 
2342+  * should be obtained from the clock that is steadily increasing. 
2343+  * 
2344+  * This function returns the number of bytes consumed, or one of the 
2345+  * following negative error codes: 
2346+  * 
2347+  * :macro:`NGHTTP3_ERR_NOMEM` 
2348+  *     Out of memory. 
2349+  * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` 
2350+  *     User callback failed. 
2351+  * 
2352+  * It may return the other error codes.  The negative error code means 
2353+  * that |conn| encountered a connection error, and the connection must 
2354+  * be closed.  Calling nghttp3 API other than `nghttp3_conn_del` 
2355+  * causes undefined behavior. 
2356+  * 
2357+  * This function is available since v1.12.0. 
2358+  */ 
2359+ NGHTTP3_EXTERN  nghttp3_ssize  nghttp3_conn_read_stream2 (nghttp3_conn  * conn ,
2360+                                                        int64_t  stream_id ,
2361+                                                        const  uint8_t  * src ,
2362+                                                        size_t  srclen , int  fin ,
2363+                                                        nghttp3_tstamp  ts );
2364+ 
22402365/** 
22412366 * @function 
22422367 * 
0 commit comments